mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Shulkers will now be able to cling to walls and ceilings
This commit is contained in:
parent
7ebfa16770
commit
63cc8903c9
1 changed files with 18 additions and 0 deletions
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue