#Why is theh so buggy?
1 messages · Page 1 of 1 (latest)
@Mixin(Entity.class)
public class EntityMixin {
@Inject(method = "setYaw",at = @At("HEAD"),cancellable = true)
private void setYaw(float yaw, CallbackInfo ci){
Entity entity = (Entity) (Object) this;
if(entity instanceof LivingEntity livingEntity&&livingEntity.hasStatusEffect(DirtyEffects.STUN)){
ci.cancel();
}
}
@Inject(method = "setPitch",at = @At("HEAD"),cancellable = true)
private void setPitch(float yaw, CallbackInfo ci){
Entity entity = (Entity) (Object) this;
if(entity instanceof LivingEntity livingEntity&&livingEntity.hasStatusEffect(DirtyEffects.STUN)){
ci.cancel();
}
}
@Inject(method = "move",at = @At("HEAD"),cancellable = true)
private void move(MovementType movementType, Vec3d movement, CallbackInfo ci){
Entity entity = (Entity) (Object) this;
if(entity instanceof LivingEntity livingEntity&&livingEntity.hasStatusEffect(DirtyEffects.STUN)){
ci.cancel();
}
}
}
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
@Inject(method = "handleFallDamage", at = @At("HEAD"), cancellable = true)
private void cancelFallDamage(float fallDistance, float damageMultiplier, DamageSource damageSource, CallbackInfoReturnable<Boolean> cir) {
LivingEntity entity = ((LivingEntity) (Object) this);
if(entity instanceof ServerPlayerEntity player) {
if(player.getInventory().getArmorStack(0).getItem()==DirtyItems.WHITE_ROOTS_BOOTS) {
if(!player.isCreative()) {
player.getInventory().getArmorStack(0).damage((int) fallDistance/4,player.getRandom(), player);
player.getInventory().getArmorStack(1).damage((int) fallDistance/4,player.getRandom(), player);
player.getInventory().getArmorStack(2).damage((int) fallDistance/4,player.getRandom(), player);
player.getInventory().getArmorStack(3).damage((int) fallDistance/4,player.getRandom(), player);
}
cir.setReturnValue(false);
}
}
}
@Inject(method = "canTarget(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"),cancellable = true)
private void canTarget(LivingEntity target, CallbackInfoReturnable<Boolean> cir){
LivingEntity entity = ((LivingEntity) (Object) this);
if(entity.hasStatusEffect(DirtyEffects.STUN)){
cir.setReturnValue(false);
}
}
@Inject(method = "canHit", at = @At("HEAD"),cancellable = true)
private void canHit(CallbackInfoReturnable<Boolean> cir){
LivingEntity entity = ((LivingEntity) (Object) this);
if(entity.hasStatusEffect(DirtyEffects.STUN)){
cir.setReturnValue(false);
}
}
}