Fix #5659 setdimension command entity filtering, avoid inverting logic
This commit is contained in:
parent
2baa05ace9
commit
abf010ac48
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue