From abf010ac48b6b1f5e40626f390f16eefbd718cb8 Mon Sep 17 00:00:00 2001 From: tterrag Date: Fri, 12 Apr 2019 19:43:27 -0400 Subject: [PATCH] Fix #5659 setdimension command entity filtering, avoid inverting logic --- .../server/command/CommandSetDimension.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java b/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java index a5990216f6..2bebe36bdf 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java +++ b/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java @@ -37,6 +37,7 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import java.util.Collection; +import java.util.function.Predicate; public class CommandSetDimension { @@ -58,7 +59,7 @@ public class CommandSetDimension private static int execute(CommandSource sender, Collection entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException { - entities.removeIf(CommandSetDimension::checkEntity); + entities.removeIf(e -> !canEntityTeleport(e)); if (entities.isEmpty()) throw NO_ENTITIES.create(); @@ -72,10 +73,10 @@ public class CommandSetDimension return 0; } - private static boolean checkEntity(Entity entity) + private static boolean canEntityTeleport(Entity entity) { - // use vanilla portal logic, try to avoid doing anything too silly - return entity.isPassenger() || entity.isBeingRidden() || entity.isNonBoss(); + // use vanilla portal logic from BlockPortal#onEntityCollision + return !entity.isPassenger() && !entity.isBeingRidden() && entity.isNonBoss(); } private static class CommandTeleporter implements ITeleporter