diff --git a/src/main/java/com/simibubi/create/foundation/item/AbstractToolItem.java b/src/main/java/com/simibubi/create/foundation/item/AbstractToolItem.java index b6f8effa9..2b8adaba9 100644 --- a/src/main/java/com/simibubi/create/foundation/item/AbstractToolItem.java +++ b/src/main/java/com/simibubi/create/foundation/item/AbstractToolItem.java @@ -7,13 +7,16 @@ import static com.simibubi.create.foundation.item.AllToolTypes.SHOVEL; import static com.simibubi.create.foundation.item.AllToolTypes.SWORD; import java.util.Collection; -import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import java.util.function.Supplier; import com.simibubi.create.foundation.packet.SimplePacketBase; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.world.ClientWorld; import net.minecraft.enchantment.Enchantment; @@ -25,6 +28,7 @@ import net.minecraft.item.Items; import net.minecraft.item.ToolItem; import net.minecraft.nbt.NBTUtil; import net.minecraft.network.PacketBuffer; +import net.minecraft.tags.BlockTags; import net.minecraft.util.ActionResultType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; @@ -41,7 +45,7 @@ public abstract class AbstractToolItem extends ToolItem { public AbstractToolItem(float attackDamageIn, float attackSpeedIn, IItemTier tier, Properties builder, AllToolTypes... types) { - super(attackDamageIn, attackSpeedIn, tier, Collections.emptySet(), setToolTypes(builder, tier, types)); + super(attackDamageIn, attackSpeedIn, tier, getEffectiveBlocks(types), setToolTypes(builder, tier, types)); toolTypes = types; } @@ -76,6 +80,32 @@ public abstract class AbstractToolItem extends ToolItem { return canEnchant; } + private static Set getEffectiveBlocks(AllToolTypes... types) { + Set blocks = new HashSet<>(); + for (AllToolTypes type : types) { + switch (type) { + case AXE: + blocks.addAll(EffectiveBlocks.AXE); + break; + case HOE: + break; + case PICKAXE: + blocks.addAll(EffectiveBlocks.PICKAXE); + break; + case SHEARS: + break; + case SHOVEL: + blocks.addAll(EffectiveBlocks.SHOVEL); + break; + case SWORD: + break; + default: + break; + } + } + return blocks; + } + private static Properties setToolTypes(Properties builder, IItemTier tier, AllToolTypes... types) { for (AllToolTypes type : types) { if (type == PICKAXE) @@ -106,8 +136,21 @@ public abstract class AbstractToolItem extends ToolItem { @Override public boolean canHarvestBlock(ItemStack stack, BlockState state) { - return super.canHarvestBlock(stack, state) || getToolTypes(stack).contains(state.getHarvestTool()) - || hasType(SWORD) && Items.WOODEN_SWORD.canHarvestBlock(stack, state); + int i = this.getTier().getHarvestLevel(); + if (getToolTypes(stack).contains(state.getHarvestTool())) + return i >= state.getHarvestLevel(); + Material material = state.getMaterial(); + boolean canHarvestMaterial = false; + if (hasType(PICKAXE)) + canHarvestMaterial |= material == Material.ROCK || material == Material.IRON || material == Material.ANVIL; + if (hasType(SHOVEL)) + canHarvestMaterial |= Items.WOODEN_SHOVEL.canHarvestBlock(stack, state); + if (hasType(SWORD)) + canHarvestMaterial |= Items.WOODEN_SWORD.canHarvestBlock(stack, state); + if (hasType(AllToolTypes.SHEARS)) + canHarvestMaterial |= Items.SHEARS.canHarvestBlock(state); + + return canHarvestMaterial; } @Override @@ -117,8 +160,16 @@ public abstract class AbstractToolItem extends ToolItem { @Override public float getDestroySpeed(ItemStack stack, BlockState state) { - if (hasType(SWORD)) - return Items.WOODEN_SWORD.getDestroySpeed(stack, state); + Material material = state.getMaterial(); + if (hasType(PICKAXE) && (material == Material.IRON || material == Material.ANVIL || material == Material.ROCK)) + return this.efficiency; + if (hasType(AXE) && (material == Material.WOOD || material == Material.PLANTS + || material == Material.TALL_PLANTS || material == Material.BAMBOO)) + return this.efficiency; + if (hasType(SWORD) + && (state.getBlock() == Blocks.COBWEB || material == Material.PLANTS || material == Material.TALL_PLANTS + || material == Material.CORAL || state.isIn(BlockTags.LEAVES) || material == Material.GOURD)) + return this.efficiency; return super.getDestroySpeed(stack, state); } diff --git a/src/main/java/com/simibubi/create/foundation/item/EffectiveBlocks.java b/src/main/java/com/simibubi/create/foundation/item/EffectiveBlocks.java new file mode 100644 index 000000000..b3d7779cb --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/item/EffectiveBlocks.java @@ -0,0 +1,67 @@ +package com.simibubi.create.foundation.item; + +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; + +public class EffectiveBlocks { + + static final Set AXE = Sets.newHashSet(Blocks.OAK_PLANKS, Blocks.SPRUCE_PLANKS, Blocks.BIRCH_PLANKS, + Blocks.JUNGLE_PLANKS, Blocks.ACACIA_PLANKS, Blocks.DARK_OAK_PLANKS, Blocks.BOOKSHELF, Blocks.OAK_WOOD, + Blocks.SPRUCE_WOOD, Blocks.BIRCH_WOOD, Blocks.JUNGLE_WOOD, Blocks.ACACIA_WOOD, Blocks.DARK_OAK_WOOD, + Blocks.OAK_LOG, Blocks.SPRUCE_LOG, Blocks.BIRCH_LOG, Blocks.JUNGLE_LOG, Blocks.ACACIA_LOG, + Blocks.DARK_OAK_LOG, Blocks.CHEST, Blocks.PUMPKIN, Blocks.CARVED_PUMPKIN, Blocks.JACK_O_LANTERN, + Blocks.MELON, Blocks.LADDER, Blocks.SCAFFOLDING, Blocks.OAK_BUTTON, Blocks.SPRUCE_BUTTON, + Blocks.BIRCH_BUTTON, Blocks.JUNGLE_BUTTON, Blocks.DARK_OAK_BUTTON, Blocks.ACACIA_BUTTON, + Blocks.OAK_PRESSURE_PLATE, Blocks.SPRUCE_PRESSURE_PLATE, Blocks.BIRCH_PRESSURE_PLATE, + Blocks.JUNGLE_PRESSURE_PLATE, Blocks.DARK_OAK_PRESSURE_PLATE, Blocks.ACACIA_PRESSURE_PLATE); + + static final Set PICKAXE = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, + Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, + Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, + Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, + Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, + Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, + Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, + Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, + Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, + Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, + Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, + Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, + Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, + Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, + Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, + Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, + Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, + Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, + Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, + Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX); + + static final Set SHOVEL = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL, + Blocks.FARMLAND, Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.RED_SAND, + Blocks.SNOW_BLOCK, Blocks.SNOW, Blocks.SOUL_SAND, Blocks.GRASS_PATH, Blocks.WHITE_CONCRETE_POWDER, + Blocks.ORANGE_CONCRETE_POWDER, Blocks.MAGENTA_CONCRETE_POWDER, Blocks.LIGHT_BLUE_CONCRETE_POWDER, + Blocks.YELLOW_CONCRETE_POWDER, Blocks.LIME_CONCRETE_POWDER, Blocks.PINK_CONCRETE_POWDER, + Blocks.GRAY_CONCRETE_POWDER, Blocks.LIGHT_GRAY_CONCRETE_POWDER, Blocks.CYAN_CONCRETE_POWDER, + Blocks.PURPLE_CONCRETE_POWDER, Blocks.BLUE_CONCRETE_POWDER, Blocks.BROWN_CONCRETE_POWDER, + Blocks.GREEN_CONCRETE_POWDER, Blocks.RED_CONCRETE_POWDER, Blocks.BLACK_CONCRETE_POWDER); + + static final Set PATHABLES = + Sets.newHashSet(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL); + + static final Map BLOCK_STRIPPING_MAP = (new Builder()) + .put(Blocks.OAK_WOOD, Blocks.STRIPPED_OAK_WOOD).put(Blocks.OAK_LOG, Blocks.STRIPPED_OAK_LOG) + .put(Blocks.DARK_OAK_WOOD, Blocks.STRIPPED_DARK_OAK_WOOD) + .put(Blocks.DARK_OAK_LOG, Blocks.STRIPPED_DARK_OAK_LOG).put(Blocks.ACACIA_WOOD, Blocks.STRIPPED_ACACIA_WOOD) + .put(Blocks.ACACIA_LOG, Blocks.STRIPPED_ACACIA_LOG).put(Blocks.BIRCH_WOOD, Blocks.STRIPPED_BIRCH_WOOD) + .put(Blocks.BIRCH_LOG, Blocks.STRIPPED_BIRCH_LOG).put(Blocks.JUNGLE_WOOD, Blocks.STRIPPED_JUNGLE_WOOD) + .put(Blocks.JUNGLE_LOG, Blocks.STRIPPED_JUNGLE_LOG).put(Blocks.SPRUCE_WOOD, Blocks.STRIPPED_SPRUCE_WOOD) + .put(Blocks.SPRUCE_LOG, Blocks.STRIPPED_SPRUCE_LOG).build(); + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java index 1b59c7226..0478e52c6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java @@ -8,6 +8,7 @@ import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; +import net.minecraft.util.Rotation; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; @@ -111,6 +112,13 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc return super.getRotationAxis(state); } + @Override + public BlockState rotate(BlockState state, Rotation rot) { + if (rot.ordinal() % 2 == 1) + state = state.cycle(AXIS_ALONG_FIRST_COORDINATE); + return super.rotate(state, rot); + } + @Override public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == getRotationAxis(state); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java index f28975c56..4a0ad5ec0 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/RotatedPillarKineticBlock.java @@ -68,7 +68,8 @@ public abstract class RotatedPillarKineticBlock extends KineticBlock { Axis preferredAxis = getPreferredAxis(context); if (preferredAxis != null && !context.isPlacerSneaking()) return this.getDefaultState().with(AXIS, preferredAxis); - return this.getDefaultState().with(AXIS, context.getNearestLookingDirection().getAxis()); + return this.getDefaultState().with(AXIS, + preferredAxis == null ? context.getFace().getAxis() : context.getNearestLookingDirection().getAxis()); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterMovementBehaviour.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterMovementBehaviour.java index 50cbd2395..8daef1d42 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/HarvesterMovementBehaviour.java @@ -53,12 +53,6 @@ public class HarvesterMovementBehaviour extends MovementBehaviour { if (world.isRemote) return; - if (stateVisited.getBlock() == Blocks.SUGAR_CANE) { - notCropButCuttable = true; - pos = pos.up(); - stateVisited = world.getBlockState(pos); - } - if (!isValidCrop(world, pos, stateVisited)) { if (isValidOther(world, pos, stateVisited)) notCropButCuttable = true; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/StorageInterfaceMovement.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/StorageInterfaceMovement.java index 168fa1fde..45815f0a2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/StorageInterfaceMovement.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/StorageInterfaceMovement.java @@ -32,7 +32,7 @@ public class StorageInterfaceMovement extends MovementBehaviour { @Override public Vec3d getActiveAreaOffset(MovementContext context) { - return new Vec3d(context.state.get(PortableStorageInterfaceBlock.FACING).getDirectionVec()).scale(.65f); + return new Vec3d(context.state.get(PortableStorageInterfaceBlock.FACING).getDirectionVec()).scale(.85f); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntity.java index bf813c162..07f52fb32 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/ContraptionEntity.java @@ -164,7 +164,7 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD } prevYaw = yaw; - yaw = angleLerp(0.2f, yaw, targetYaw); + yaw = angleLerp(0.4f, yaw, targetYaw); boolean wasStalled = isStalled(); tickActors(movementVector); @@ -220,18 +220,23 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD if (getContraption() instanceof BearingContraption) { BearingContraption bc = (BearingContraption) getContraption(); Direction facing = bc.getFacing(); - if (VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis())) { - context.motion = new Vec3d(facing.getDirectionVec()).scale( - facing.getAxis().getCoordinate(roll - prevRoll, yaw - prevYaw, pitch - prevPitch)); - context.relativeMotion = context.motion; - int timer = context.data.getInt("StationaryTimer"); - if (timer > 0) { - context.data.putInt("StationaryTimer", timer - 1); - } else { - context.data.putInt("StationaryTimer", 20); - newPosVisited = true; + Vec3d activeAreaOffset = actor.getActiveAreaOffset(context); + if (activeAreaOffset.mul(VecHelper.planeByNormal(new Vec3d(facing.getDirectionVec()))) + .equals(Vec3d.ZERO)) { + if (VecHelper.onSameAxis(blockInfo.pos, BlockPos.ZERO, facing.getAxis())) { + context.motion = new Vec3d(facing.getDirectionVec()).scale( + facing.getAxis().getCoordinate(roll - prevRoll, yaw - prevYaw, pitch - prevPitch)); + context.relativeMotion = context.motion; + int timer = context.data.getInt("StationaryTimer"); + if (timer > 0) { + context.data.putInt("StationaryTimer", timer - 1); + } else { + context.data.putInt("StationaryTimer", 20); + newPosVisited = true; + } } } + } } @@ -423,6 +428,9 @@ public class ContraptionEntity extends Entity implements IEntityAdditionalSpawnD public void preventMovedEntitiesFromGettingStuck() { Vec3d stuckTest = new Vec3d(0, -2, 0); for (Entity e : collidingEntities) { + e.fallDistance = 0; + e.onGround = true; + Vec3d vec = stuckTest; AxisAlignedBB axisalignedbb = e.getBoundingBox().offset(0, 2, 0); ISelectionContext iselectioncontext = ISelectionContext.forEntity(this); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java index 49a8281fd..f685d9719 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/StructureTransform.java @@ -1,7 +1,11 @@ package com.simibubi.create.modules.contraptions.components.contraptions; +import static net.minecraft.state.properties.BlockStateProperties.AXIS; +import static net.minecraft.state.properties.BlockStateProperties.FACING; + import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.utility.VecHelper; +import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.modules.contraptions.components.contraptions.chassis.AbstractChassisBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope; @@ -10,7 +14,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.SlabBlock; import net.minecraft.block.StairsBlock; import net.minecraft.state.BooleanProperty; -import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.Half; import net.minecraft.state.properties.SlabType; import net.minecraft.util.Direction; @@ -136,12 +139,16 @@ public class StructureTransform { return state; } - if (state.has(BlockStateProperties.FACING)) { - state = - state.with(BlockStateProperties.FACING, transformFacing(state.get(BlockStateProperties.FACING))); + if (state.has(FACING)) { + Direction newFacing = transformFacing(state.get(FACING)); + if (state.has(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE)) { + if (rotationAxis == newFacing.getAxis() && rotation.ordinal() % 2 == 1) + state = state.cycle(DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE); + } + state = state.with(FACING, newFacing); - } else if (state.has(BlockStateProperties.AXIS)) { - state = state.with(BlockStateProperties.AXIS, transformAxis(state.get(BlockStateProperties.AXIS))); + } else if (state.has(AXIS)) { + state = state.with(AXIS, transformAxis(state.get(AXIS))); } else if (rotation == Rotation.CLOCKWISE_180) { state = state.rotate(rotation); @@ -172,7 +179,7 @@ public class StructureTransform { if (rotation == Rotation.NONE) return state; - BlockState rotated = state.with(BlockStateProperties.AXIS, transformAxis(state.get(BlockStateProperties.AXIS))); + BlockState rotated = state.with(AXIS, transformAxis(state.get(AXIS))); AbstractChassisBlock block = (AbstractChassisBlock) state.getBlock(); for (Direction face : Direction.values()) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/CartAssemblerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/CartAssemblerBlock.java index 7a47059bd..f16be373f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/CartAssemblerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/CartAssemblerBlock.java @@ -22,7 +22,6 @@ import net.minecraft.state.properties.RailShape; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; @@ -63,16 +62,6 @@ public class CartAssemblerBlock extends AbstractRailBlock { public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) { if (!cart.canBeRidden()) return; - - Vec3d p = cart.getPositionVec(); - Vec3d m = cart.getMotion(); - Vec3d p2 = p.add(m); - Direction facing = Direction.getFacingFromVector(m.x, m.y, m.z); - Axis axis = facing.getAxis(); - double coord = axis.getCoordinate(pos.getX(), pos.getY(), pos.getZ()) + .5 + .25f * facing.getAxisDirection().getOffset(); - if ((axis.getCoordinate(p.x, p.y, p.z) > coord) == (axis.getCoordinate(p2.x, p2.y, p2.z) % 1 > coord)) - return; - if (state.get(POWERED)) disassemble(world, pos, cart); else diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerMovementBehaviour.java index 784c7aebd..a700fced5 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -17,6 +17,7 @@ import com.simibubi.create.modules.logistics.item.filter.FilterItem; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.ListNBT; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -89,13 +90,15 @@ public class DeployerMovementBehaviour extends MovementBehaviour { public void stopMoving(MovementContext context) { if (context.world.isRemote) return; - tryDisposeOfEverything(context); + DeployerFakePlayer player = getPlayer(context); if (player == null) return; + + context.tileData.put("Inventory", player.inventory.write(new ListNBT())); player.remove(); } - + private void tryGrabbingItem(MovementContext context) { DeployerFakePlayer player = getPlayer(context); if (player == null) @@ -107,18 +110,6 @@ public class DeployerMovementBehaviour extends MovementBehaviour { } } - private void tryDisposeOfEverything(MovementContext context) { - DeployerFakePlayer player = getPlayer(context); - if (player == null) - return; - ItemStack held = player.getHeldItemMainhand(); - if (!held.isEmpty()) { - dropItem(context, held); - player.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY); - } - tryDisposeOfExcess(context); - } - private void tryDisposeOfExcess(MovementContext context) { DeployerFakePlayer player = getPlayer(context); if (player == null) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java index 6a1ad4489..66170283d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java @@ -327,6 +327,8 @@ public class DeployerTileEntity extends KineticTileEntity { timer = compound.getInt("Timer"); deferredInventoryList = compound.getList("Inventory", NBT.TAG_COMPOUND); overflowItems = NBTHelper.readItemList(compound.getList("Overflow", NBT.TAG_COMPOUND)); + if (compound.contains("HeldItem")) + heldItem = ItemStack.read(compound.getCompound("HeldItem")); super.read(compound); } @@ -336,6 +338,7 @@ public class DeployerTileEntity extends KineticTileEntity { compound.putString("State", NBTHelper.writeEnum(state)); compound.putInt("Timer", timer); if (player != null) { + compound.put("HeldItem", player.getHeldItemMainhand().serializeNBT()); ListNBT invNBT = new ListNBT(); player.inventory.write(invNBT); compound.put("Inventory", invNBT); @@ -360,8 +363,6 @@ public class DeployerTileEntity extends KineticTileEntity { @Override public void readClientUpdate(CompoundNBT tag) { reach = tag.getFloat("Reach"); - if (tag.contains("HeldItem")) - heldItem = ItemStack.read(tag.getCompound("HeldItem")); if (tag.contains("Particle")) { ItemStack particleStack = ItemStack.read(tag.getCompound("Particle")); SandPaperItem.spawnParticles(VecHelper.getCenterOf(pos).add(getMovementVector().scale(2f)), particleStack, diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java index ca55912e6..3a1630c42 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java @@ -77,9 +77,9 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer