Shulkers will now be able to cling to walls and ceilings

This commit is contained in:
Sollace 2020-09-24 17:41:04 +02:00
parent 7ebfa16770
commit 63cc8903c9

View file

@ -7,7 +7,11 @@ import com.minelittlepony.unicopia.mixin.MixinShulkerEntity;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.ShulkerEntity; import net.minecraft.entity.mob.ShulkerEntity;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> { public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
@Override @Override
@ -43,5 +47,19 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
} }
} }
} }
Direction attachmentFace = shulker.getAttachedFace();
BlockPos pos = shulker.getBlockPos().offset(attachmentFace);
boolean noGravity = !shulker.isOnGround() && !shulker.world.isAir(pos)
&& (attachmentFace == Direction.UP || attachmentFace.getAxis() != Axis.Y);
source.getEntity().setNoGravity(noGravity);
if (noGravity && source.getEntity().isSneaking()) {
Vec3d vel = source.getEntity().getVelocity();
if (vel.y > 0) {
source.getEntity().setVelocity(vel.multiply(1, 0.8, 1));
}
}
} }
} }