Make fan and nozzles not push players flying in creative

This commit is contained in:
reidbhuntley 2021-05-24 15:19:54 -04:00
parent 0cd49317d7
commit 3f31b765dd
2 changed files with 12 additions and 8 deletions

View file

@ -89,8 +89,7 @@ public class AirCurrent {
protected void tickAffectedEntities(World world, Direction facing) {
for (Iterator<Entity> iterator = caughtEntities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next();
if (!entity.isAlive() || !entity.getBoundingBox()
.intersects(bounds)) {
if (!entity.isAlive() || !entity.getBoundingBox().intersects(bounds) || isPlayerCreativeFlying(entity)) {
iterator.remove();
continue;
}
@ -389,4 +388,12 @@ public class AirCurrent {
isClientPlayerInAirCurrent = false;
}
public static boolean isPlayerCreativeFlying(Entity entity) {
if (entity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) entity;
return player.isCreative() && player.abilities.isFlying;
}
return false;
}
}

View file

@ -49,7 +49,7 @@ public class NozzleTileEntity extends SmartTileEntity {
compound.putFloat("Range", range);
compound.putBoolean("Pushing", pushing);
}
@Override
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
super.fromTag(state, compound, clientPacket);
@ -95,8 +95,7 @@ public class NozzleTileEntity extends SmartTileEntity {
continue;
double distance = diff.length();
if (distance > range || entity.isSneaking()
|| (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) {
if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity)) {
iterator.remove();
continue;
}
@ -153,10 +152,8 @@ public class NozzleTileEntity extends SmartTileEntity {
.subtract(center);
double distance = diff.length();
if (distance > range || entity.isSneaking()
|| (entity instanceof PlayerEntity && ((PlayerEntity) entity).isCreative())) {
if (distance > range || entity.isSneaking() || AirCurrent.isPlayerCreativeFlying(entity))
continue;
}
boolean canSee = canSee(entity);
if (!canSee) {