persistentParrots = incompatibleParrots with Bole Handbook
800020h opened this issue · 3 comments
versions:
- Minecraft 1.19.2
- Fabric Loader 0.14.21
- bole-1.1.3-mc1.19.2-fabric
- fabric-api-0.76.1+1.19.2
- fabric-carpet-1.19.2-1.4.84+v221018
observed behaviour:
when bole and carpet are both present
and persistentParrots
is true
it works as expected
when persistentParrots
is false
bole's fallDistanceToDropShoulderEntities
config doesn't work
expected behaviour:
when persistentParrots
is false
bole's fallDistanceToDropShoulderEntities
config would work
notes:
fallDistanceToDropShoulderEntities
makes it so you can configure how far you need to fall before parrots leave your shoulder- I had
fallDistanceToDropShoulderEntities
set for 3 blocks - testing has to be done in survival
bole link:
bole config used:
.minecraft/config/bole.json
{
"shoulderCreatureHudPosition": "NONE",
"notifyWhenLeashFallFromPlayer": false,
"receiveWanderingTraderSpawnBroadcasts": false,
"highlightEntitiesBlindnessTime": 40,
"allowHotKeyToOpenBoleHandbookScreen": false,
"blockAccidentalInjuryToPets": false,
"petsCanTeleportToMoreBlocks": false,
"fallDistanceToDropShoulderEntities": 3.0,
"forbidToSetNetherPortalCooldownOfOtherPlayers": false,
"broadcastWhenWanderingTraderSpawn": false,
"bannedEntitySettings": []
}
The related raw logic is:
// mojang mapping: public void aiStep()
if (!this.level.isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) {
this.removeEntitiesOnShoulder();
}
// or yarn mapping: public void tickMovement()
if (!this.world.isClient && (this.fallDistance > 0.5F || this.isTouchingWater()) || this.abilities.flying || this.isSleeping() || this.inPowderSnow) {
this.dropShoulderEntities();
}
And in the mixin file src/main/java/xienaoban/minecraft/bole/mixin/MixinPlayerEntity.java
of bole:
@Redirect(method = "tickMovement()V", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;fallDistance:F", opcode = Opcodes.GETFIELD))
private float injected(PlayerEntity instance) {
float time = Configs.getInstance().getFallDistanceToDropShoulderEntities();
return instance.fallDistance / (Math.max(time, 0.001F) * 2);
}
I rewrote the logic of this.fallDistance > 0.5F
.
But in the mixin file src/main/java/carpet/mixins/Player_parrotMixin.java
of carpet:
@Inject(method = "aiStep", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1,
target = "Lnet/minecraft/world/entity/player/Player;playShoulderEntityAmbientSound(Lnet/minecraft/nbt/CompoundTag;)V"))
private void onTickMovement(CallbackInfo ci)
{
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
// →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→ the problem is here ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
if (!this.level.isClientSide && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || this.abilities.flying || isSleeping()))
{
this.removeEntitiesOnShoulder();
}
}
Carpet rewrote the whole logic, so my logic doesn't work anymore.
Maybe a better solution is to put the judgment parrots_will_drop
into the if statement:
// ...
if (!this.level.isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) {
// 👇inject something like the following:
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
if (parrots_will_drop) {
this.removeEntitiesOnShoulder();
}
// 👆end of injection
this.removeEntitiesOnShoulder(); // carpet has already mocked this line by cancelDropShoulderEntities1()
}