Open 800020h opened 10 months ago
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()
}
versions:
observed behaviour:
when bole and carpet are both present and
persistentParrots
istrue
it works as expected whenpersistentParrots
isfalse
bole'sfallDistanceToDropShoulderEntities
config doesn't workexpected behaviour:
when
persistentParrots
isfalse
bole'sfallDistanceToDropShoulderEntities
config would worknotes:
fallDistanceToDropShoulderEntities
makes it so you can configure how far you need to fall before parrots leave your shoulderfallDistanceToDropShoulderEntities
set for 3 blocksbole link:
https://modrinth.com/mod/bole
bole config used:
.minecraft/config/bole.json