Fix #5659 setdimension command entity filtering, avoid inverting logic

This commit is contained in:
tterrag 2019-04-12 19:43:27 -04:00
parent 2baa05ace9
commit abf010ac48
1 changed files with 5 additions and 4 deletions

View File

@ -37,6 +37,7 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import java.util.Collection; import java.util.Collection;
import java.util.function.Predicate;
public class CommandSetDimension public class CommandSetDimension
{ {
@ -58,7 +59,7 @@ public class CommandSetDimension
private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException private static int execute(CommandSource sender, Collection<? extends Entity> entities, DimensionType dim, BlockPos pos) throws CommandSyntaxException
{ {
entities.removeIf(CommandSetDimension::checkEntity); entities.removeIf(e -> !canEntityTeleport(e));
if (entities.isEmpty()) if (entities.isEmpty())
throw NO_ENTITIES.create(); throw NO_ENTITIES.create();
@ -72,10 +73,10 @@ public class CommandSetDimension
return 0; 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 // use vanilla portal logic from BlockPortal#onEntityCollision
return entity.isPassenger() || entity.isBeingRidden() || entity.isNonBoss(); return !entity.isPassenger() && !entity.isBeingRidden() && entity.isNonBoss();
} }
private static class CommandTeleporter implements ITeleporter private static class CommandTeleporter implements ITeleporter