From 3f31b765dd3401fc00736076575cb6d61695ef70 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Mon, 24 May 2021 15:19:54 -0400 Subject: [PATCH] Make fan and nozzles not push players flying in creative --- .../contraptions/components/fan/AirCurrent.java | 11 +++++++++-- .../contraptions/components/fan/NozzleTileEntity.java | 9 +++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java index 0440de076..3b4d2ba91 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/AirCurrent.java @@ -89,8 +89,7 @@ public class AirCurrent { protected void tickAffectedEntities(World world, Direction facing) { for (Iterator 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; + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java index 945e8498c..74c7a83b4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java @@ -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) {