1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-19 05:32:55 +00:00

Don't push non-pushable entities

Fixes #949
This commit is contained in:
Jonathan Coates 2021-12-20 17:58:39 +00:00
parent 114261944a
commit 5eedea1bbb
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -24,6 +24,7 @@ import dan200.computercraft.shared.util.HolidayUtil;
import dan200.computercraft.shared.util.InventoryDelegate; import dan200.computercraft.shared.util.InventoryDelegate;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.material.PushReaction;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.MoverType; import net.minecraft.entity.MoverType;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
@ -34,7 +35,6 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.tags.FluidTags; import net.minecraft.tags.FluidTags;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -48,6 +48,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import static dan200.computercraft.shared.common.IColouredItem.NBT_COLOUR; import static dan200.computercraft.shared.common.IColouredItem.NBT_COLOUR;
import static dan200.computercraft.shared.util.WaterloggableHelpers.WATERLOGGED; import static dan200.computercraft.shared.util.WaterloggableHelpers.WATERLOGGED;
@ -65,6 +66,8 @@ public class TurtleBrain implements ITurtleAccess
private static final int ANIM_DURATION = 8; private static final int ANIM_DURATION = 8;
public static final Predicate<Entity> PUSHABLE_ENTITY = entity -> !entity.isSpectator() && entity.getPistonPushReaction() != PushReaction.IGNORE;
private TileTurtle owner; private TileTurtle owner;
private ComputerProxy proxy; private ComputerProxy proxy;
private GameProfile owningPlayer; private GameProfile owningPlayer;
@ -887,7 +890,7 @@ public class TurtleBrain implements ITurtleAccess
} }
AxisAlignedBB aabb = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ); AxisAlignedBB aabb = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
List<Entity> list = world.getEntitiesOfClass( Entity.class, aabb, EntityPredicates.NO_SPECTATORS ); List<Entity> list = world.getEntitiesOfClass( Entity.class, aabb, PUSHABLE_ENTITY );
if( !list.isEmpty() ) if( !list.isEmpty() )
{ {
double pushStep = 1.0f / ANIM_DURATION; double pushStep = 1.0f / ANIM_DURATION;