diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 4560fb109..67b0fd927 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -93,19 +93,19 @@ import com.simibubi.create.content.logistics.block.diodes.ToggleLatchGenerator; import com.simibubi.create.content.logistics.block.extractor.ExtractorBlock; import com.simibubi.create.content.logistics.block.extractor.LinkedExtractorBlock; import com.simibubi.create.content.logistics.block.extractor.VerticalExtractorGenerator; +import com.simibubi.create.content.logistics.block.funnel.AndesiteBeltFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.AndesiteChuteFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.AndesiteFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.BeltFunnelGenerator; +import com.simibubi.create.content.logistics.block.funnel.BrassBeltFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.BrassChuteFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.BrassFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.ChuteFunnelGenerator; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateBlock; import com.simibubi.create.content.logistics.block.inventories.CreativeCrateBlock; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmBlock; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmItem; import com.simibubi.create.content.logistics.block.packager.PackagerBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.AndesiteBeltFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.AndesiteChuteFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.AndesiteFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.BeltFunnelGenerator; -import com.simibubi.create.content.logistics.block.realityFunnel.BrassBeltFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.BrassChuteFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.BrassFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.ChuteFunnelGenerator; import com.simibubi.create.content.logistics.block.redstone.AnalogLeverBlock; import com.simibubi.create.content.logistics.block.redstone.NixieTubeBlock; import com.simibubi.create.content.logistics.block.redstone.NixieTubeGenerator; diff --git a/src/main/java/com/simibubi/create/AllShapes.java b/src/main/java/com/simibubi/create/AllShapes.java index 53980cc8f..71626ae70 100644 --- a/src/main/java/com/simibubi/create/AllShapes.java +++ b/src/main/java/com/simibubi/create/AllShapes.java @@ -28,8 +28,6 @@ public class AllShapes { CASING_11PX = shape(0, 0, 0, 16, 11, 16).forDirectional(), MOTOR_BLOCK = shape(3, 0, 3, 13, 14, 13).forDirectional(), FOUR_VOXEL_POLE = shape(6, 0, 6, 10, 16, 10).forAxis(), SIX_VOXEL_POLE = shape(5, 0, 5, 11, 16, 11).forAxis(), - BELT_FUNNEL = shape(3, -4, 11, 13, 8, 17).forHorizontal(SOUTH), - FUNNEL = shape(1, 1, 13, 15, 15, 17).forDirectional(SOUTH), EXTRACTOR = shape(4, 2, 11, 12, 10, 17).forDirectional(SOUTH) .withVerticalShapes(cuboid(4, 11, 4, 12, 17, 12)), TRANSPOSER = shape(4, 4, -1, 12, 12, 1).add(5, 5, 0, 11, 11, 16) @@ -65,11 +63,11 @@ public class AllShapes { NIXIE_TUBE_CEILING = shape(0, 12, 0, 16, 16, 16).add(9, 1, 5, 15, 16, 11) .add(1, 1, 5, 7, 16, 11) .forHorizontalAxis(), - REALITY_FUNNEL = shape(3, -2, 3, 13, 2, 13).add(2, 2, 2, 14, 6, 14) + FUNNEL = shape(3, -2, 3, 13, 2, 13).add(2, 2, 2, 14, 6, 14) .add(1, 6, 1, 15, 10, 15) .add(0, 10, 0, 16, 16, 16) .forDirectional(UP), - REALITY_FUNNEL_COLLISION = shape(3, -2, 3, 13, 2, 13).add(2, 2, 2, 14, 6, 14) + FUNNEL_COLLISION = shape(3, -2, 3, 13, 2, 13).add(2, 2, 2, 14, 6, 14) .add(1, 6, 1, 15, 10, 15) .add(0, 10, 0, 16, 13, 16) .forDirectional(UP), diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 044d4fa25..f7b0b865f 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -81,14 +81,14 @@ import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterRend import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterTileEntity; import com.simibubi.create.content.logistics.block.extractor.ExtractorTileEntity; import com.simibubi.create.content.logistics.block.extractor.LinkedExtractorTileEntity; +import com.simibubi.create.content.logistics.block.funnel.FunnelRenderer; +import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity; import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmRenderer; import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity; import com.simibubi.create.content.logistics.block.packager.PackagerRenderer; import com.simibubi.create.content.logistics.block.packager.PackagerTileEntity; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelRenderer; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelTileEntity; import com.simibubi.create.content.logistics.block.redstone.AnalogLeverRenderer; import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntity; import com.simibubi.create.content.logistics.block.redstone.NixieTubeRenderer; @@ -227,8 +227,8 @@ public class AllTileEntities { public static final TileEntityEntry DEPOT = register("depot", DepotTileEntity::new, AllBlocks.DEPOT); - public static final TileEntityEntry REALITY_FUNNEL = register("reality_funnel", - RealityFunnelTileEntity::new, AllBlocks.BRASS_FUNNEL, AllBlocks.BRASS_BELT_FUNNEL, AllBlocks.BRASS_CHUTE_FUNNEL, + public static final TileEntityEntry FUNNEL = register("funnel", + FunnelTileEntity::new, AllBlocks.BRASS_FUNNEL, AllBlocks.BRASS_BELT_FUNNEL, AllBlocks.BRASS_CHUTE_FUNNEL, AllBlocks.ANDESITE_FUNNEL, AllBlocks.ANDESITE_BELT_FUNNEL, AllBlocks.ANDESITE_CHUTE_FUNNEL); public static final TileEntityEntry PACKAGER = register("packager", PackagerTileEntity::new, AllBlocks.PACKAGER); @@ -312,7 +312,7 @@ public class AllTileEntities { bind(LINKED_EXTRACTOR, SmartTileEntityRenderer::new); bind(TRANSPOSER, SmartTileEntityRenderer::new); bind(LINKED_TRANSPOSER, SmartTileEntityRenderer::new); - bind(REALITY_FUNNEL, RealityFunnelRenderer::new); + bind(FUNNEL, FunnelRenderer::new); bind(BELT_TUNNEL, BeltTunnelRenderer::new); bind(MECHANICAL_ARM, ArmRenderer::new); bind(BELT_OBSERVER, BeltObserverRenderer::new); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index 929863ac6..8d7b2347e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -21,6 +21,7 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltBlock.Slope; import com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory; import com.simibubi.create.content.contraptions.relays.belt.transport.BeltMovementHandler; import com.simibubi.create.content.contraptions.relays.belt.transport.BeltMovementHandler.TransportedEntityInfo; +import com.simibubi.create.content.contraptions.relays.belt.transport.BeltTunnelInteractionHandler; import com.simibubi.create.content.contraptions.relays.belt.transport.ItemHandlerBeltSegment; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -432,6 +433,9 @@ public class BeltTileEntity extends KineticTileEntity { transportedStack.insertedAt = index; transportedStack.insertedFrom = side; transportedStack.prevBeltPosition = transportedStack.beltPosition; + + BeltTunnelInteractionHandler.flapTunnel(nextInventory, index, side.getOpposite(), true); + nextInventory.addItem(transportedStack); nextBeltController.markDirty(); nextBeltController.sendData(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java index a169ac0ac..7a5b372f4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltFunnelInteractionHandler.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.relays.belt.transport; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; -import com.simibubi.create.content.logistics.block.realityFunnel.BeltFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelTileEntity; +import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InsertingBehaviour; @@ -45,10 +45,10 @@ public class BeltFunnelInteractionHandler { return true; TileEntity te = world.getTileEntity(funnelPos); - if (!(te instanceof RealityFunnelTileEntity)) + if (!(te instanceof FunnelTileEntity)) return true; - RealityFunnelTileEntity funnelTE = (RealityFunnelTileEntity) te; + FunnelTileEntity funnelTE = (FunnelTileEntity) te; InsertingBehaviour inserting = TileEntityBehaviour.get(funnelTE, InsertingBehaviour.TYPE); FilteringBehaviour filtering = TileEntityBehaviour.get(funnelTE, FilteringBehaviour.TYPE); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java index b476533e8..7e6102ef9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltTunnelInteractionHandler.java @@ -1,8 +1,5 @@ package com.simibubi.create.content.contraptions.relays.belt.transport; -import java.util.List; - -import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock.Slope; import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; @@ -46,40 +43,18 @@ public class BeltTunnelInteractionHandler { BeltTileEntity belt = beltInventory.belt; BlockPos pos = BeltHelper.getPositionForOffset(belt, offset) .up(); - if (!AllBlocks.BRASS_TUNNEL.has(belt.getWorld() - .getBlockState(pos))) + if (!(belt.getWorld() + .getBlockState(pos) + .getBlock() instanceof BeltTunnelBlock)) return false; TileEntity te = belt.getWorld() .getTileEntity(pos); if (te == null || !(te instanceof BeltTunnelTileEntity)) return false; - Direction flapFacing = movementDirection.getOpposite(); - - BeltTunnelTileEntity tunnel = (BeltTunnelTileEntity) te; - if (!tunnel.flaps.containsKey(flapFacing)) - return false; - if (!tunnel.syncedFlaps.containsKey(flapFacing)) - return false; - ItemStack heldItem = tunnel.syncedFlaps.get(flapFacing); - if (heldItem == null) { - tunnel.syncedFlaps.put(flapFacing, ItemStack.EMPTY); - belt.sendData(); - return false; - } - if (heldItem == ItemStack.EMPTY) { - tunnel.syncedFlaps.put(flapFacing, stack); - return true; - } - - List group = BeltTunnelBlock.getSynchronizedGroup(belt.getWorld(), pos, flapFacing); - for (BeltTunnelTileEntity otherTunnel : group) - if (otherTunnel.syncedFlaps.get(flapFacing) == ItemStack.EMPTY) - return true; - for (BeltTunnelTileEntity otherTunnel : group) - otherTunnel.syncedFlaps.put(flapFacing, null); - - return true; + // TODO: ask TE if item can be inserted + + return false; } public static void flapTunnel(BeltInventory beltInventory, int offset, Direction side, boolean inward) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java index 722a4789b..b5deacd05 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelBlock.java @@ -1,14 +1,11 @@ package com.simibubi.create.content.logistics.block.belts.tunnel; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock; import com.simibubi.create.content.contraptions.relays.belt.BeltBlock.Slope; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; @@ -71,13 +68,20 @@ public class BeltTunnelBlock extends Block implements ITE, @Override public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + BlockState blockState = worldIn.getBlockState(pos.down()); + if (!isValidPositionForPlacement(state, worldIn, pos)) + return false; + if (!blockState.get(BeltBlock.CASING)) + return false; + return true; + } + + public boolean isValidPositionForPlacement(BlockState state, IWorldReader worldIn, BlockPos pos) { BlockState blockState = worldIn.getBlockState(pos.down()); if (!AllBlocks.BELT.has(blockState)) return false; if (blockState.get(BeltBlock.SLOPE) != Slope.HORIZONTAL) return false; - if (!blockState.get(BeltBlock.CASING)) - return false; return true; } @@ -98,10 +102,12 @@ public class BeltTunnelBlock extends Block implements ITE, @Override public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { + if (facing.getAxis() + .isVertical()) + return state; if (!(worldIn instanceof WrappedWorld)) withTileEntityDo(worldIn, currentPos, BeltTunnelTileEntity::initFlaps); BlockState tunnelState = getTunnelState(worldIn, currentPos); - if (tunnelState.get(HORIZONTAL_AXIS) == state.get(HORIZONTAL_AXIS)) { if (hasWindow(tunnelState) == hasWindow(state)) return state; @@ -121,29 +127,6 @@ public class BeltTunnelBlock extends Block implements ITE, } } - public static List getSynchronizedGroup(World world, BlockPos pos, Direction flapFacing) { - List group = new ArrayList<>(); - Direction searchDirection = flapFacing.rotateY(); - - for (Direction d : Arrays.asList(searchDirection, searchDirection.getOpposite())) { - BlockPos currentPos = pos; - while (true) { - if (!world.isBlockPresent(currentPos)) - break; - TileEntity te = world.getTileEntity(currentPos); - if (te == null || !(te instanceof BeltTunnelTileEntity)) - break; - BeltTunnelTileEntity tunnel = (BeltTunnelTileEntity) te; - if (!tunnel.syncedFlaps.containsKey(flapFacing)) - break; - group.add(tunnel); - currentPos = currentPos.offset(d); - } - } - - return group; - } - private BlockState getTunnelState(IBlockReader reader, BlockPos pos) { BlockState state = getDefaultState(); BlockState belt = reader.getBlockState(pos.down()); @@ -175,7 +158,13 @@ public class BeltTunnelBlock extends Block implements ITE, Direction fw = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); BlockState blockState1 = reader.getBlockState(pos.offset(fw)); BlockState blockState2 = reader.getBlockState(pos.offset(fw.getOpposite())); - if (blockState1.getBlock() instanceof BeltTunnelBlock && blockState2.getBlock() instanceof BeltTunnelBlock) + boolean valid1 = + blockState1.getBlock() instanceof BeltTunnelBlock || blockState1.getBlock() instanceof BeltFunnelBlock + && blockState1.get(BeltFunnelBlock.HORIZONTAL_FACING) == fw.getOpposite(); + boolean valid2 = + blockState2.getBlock() instanceof BeltTunnelBlock || blockState2.getBlock() instanceof BeltFunnelBlock + && blockState2.get(BeltFunnelBlock.HORIZONTAL_FACING) == fw; + if (valid1 && valid2) state = state.with(SHAPE, Shape.WINDOW); } @@ -185,10 +174,6 @@ public class BeltTunnelBlock extends Block implements ITE, @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { - // Toggle sync - if (toggleSync(context.getWorld(), context.getPos(), context.getFace())) - return ActionResultType.SUCCESS; - // Toggle windows if (!hasWindow(state)) return IWrenchable.super.onWrenched(state, context); @@ -212,14 +197,6 @@ public class BeltTunnelBlock extends Block implements ITE, return ActionResultType.SUCCESS; } - private boolean toggleSync(World world, BlockPos pos, Direction face) { - TileEntity te = world.getTileEntity(pos); - if (te == null || !(te instanceof BeltTunnelTileEntity)) - return false; - BeltTunnelTileEntity tunnel = (BeltTunnelTileEntity) te; - return tunnel.toggleSyncForFlap(face); - } - @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java new file mode 100644 index 000000000..c083c15bc --- /dev/null +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelItem.java @@ -0,0 +1,47 @@ +package com.simibubi.create.content.logistics.block.belts.tunnel; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.contraptions.relays.belt.BeltHelper; +import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; +import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity.CasingType; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.world.World; + +public class BeltTunnelItem extends BlockItem { + + public BeltTunnelItem(Block p_i48527_1_, Properties p_i48527_2_) { + super(p_i48527_1_, p_i48527_2_); + } + + @Override + protected boolean canPlace(BlockItemUseContext ctx, BlockState state) { + PlayerEntity playerentity = ctx.getPlayer(); + ISelectionContext iselectioncontext = + playerentity == null ? ISelectionContext.dummy() : ISelectionContext.forEntity(playerentity); + World world = ctx.getWorld(); + BlockPos pos = ctx.getPos(); + return (!this.checkPosition() || AllBlocks.ANDESITE_TUNNEL.get() + .isValidPositionForPlacement(state, world, pos)) && world.canPlace(state, pos, iselectioncontext); + } + + @Override + protected boolean onBlockPlaced(BlockPos pos, World world, PlayerEntity p_195943_3_, ItemStack p_195943_4_, + BlockState state) { + boolean flag = super.onBlockPlaced(pos, world, p_195943_3_, p_195943_4_, state); + if (!world.isRemote) { + BeltTileEntity belt = BeltHelper.getSegmentTE(world, pos.down()); + if (belt != null && belt.casing == CasingType.NONE) + belt.setCasingType(AllBlocks.ANDESITE_TUNNEL.has(state) ? CasingType.ANDESITE : CasingType.BRASS); + } + return flag; + } + +} diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index d728b837a..e87dbc1da 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -4,11 +4,9 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -28,7 +26,6 @@ public class BeltTunnelRenderer extends SafeTileEntityRenderer flaps; - public HashMap syncedFlaps; private LazyOptional cap = LazyOptional.empty(); - private boolean initialize; - private List> flapsToSend; public BeltTunnelTileEntity(TileEntityType type) { super(type); flaps = new HashMap<>(); - syncedFlaps = new HashMap<>(); - initialize = true; flapsToSend = new LinkedList<>(); } - @Override - public LazyOptional getCapability(Capability capability, Direction side) { - - if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - if (!this.cap.isPresent()) { - if (AllBlocks.BELT.has(world.getBlockState(pos.down()))) { - TileEntity teBelow = world.getTileEntity(pos.down()); - if (teBelow != null) { - T capBelow = teBelow.getCapability(capability, Direction.UP) - .orElse(null); - if (capBelow != null) { - cap = LazyOptional.of(() -> capBelow) - .cast(); - } - } - } - } - return this.cap.cast(); - } - return super.getCapability(capability, side); - } - @Override public void remove() { super.remove(); @@ -76,40 +48,14 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT @Override public CompoundNBT write(CompoundNBT compound) { - CompoundNBT dyedFlapsNBT = new CompoundNBT(); - syncedFlaps.forEach((direction, pair) -> { - dyedFlapsNBT.putBoolean(direction.name(), true); - }); - compound.put("syncedFlaps", dyedFlapsNBT); return super.write(compound); } @Override public void read(CompoundNBT compound) { - if (compound.contains("syncedFlaps")) { - syncedFlaps.clear(); - CompoundNBT dyedFlapsNBT = compound.getCompound("syncedFlaps"); - for (Direction direction : Direction.values()) { - if (dyedFlapsNBT.contains(direction.name())) - syncedFlaps.put(direction, ItemStack.EMPTY); - } - } super.read(compound); } - public boolean toggleSyncForFlap(Direction face) { - if (!flaps.containsKey(face)) - return false; - if (syncedFlaps.containsKey(face)) - syncedFlaps.remove(face); - else - syncedFlaps.put(face, ItemStack.EMPTY); - - markDirty(); - sendData(); - return true; - } - @Override public CompoundNBT writeToClient(CompoundNBT tag) { CompoundNBT writeToClient = super.writeToClient(tag); @@ -138,16 +84,14 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT Direction side = Direction.byIndex(flap.getInt("Flap")); flap(side, flap.getBoolean("FlapInward")); } - } else + } else { initFlaps(); + } } public void initFlaps() { - if (!world.isRemote) { + if (!world.isRemote) sendData(); - } - - initialize = false; flaps.clear(); BlockState tunnelState = getBlockState(); for (Direction direction : Direction.values()) { @@ -168,7 +112,8 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT if (!positive && shape == Shape.T_RIGHT) continue; } - flaps.put(direction, new InterpolatedChasingValue().target(0) + flaps.put(direction, new InterpolatedChasingValue().start(.25f) + .target(0) .withSpeed(.05f)); } } @@ -184,10 +129,15 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT flapsToSend.add(Pair.of(side, inward)); } + @Override + public void initialize() { + super.initialize(); + initFlaps(); + } + @Override public void tick() { - if (initialize) - initFlaps(); + super.tick(); if (!world.isRemote) { if (!flapsToSend.isEmpty()) sendData(); @@ -196,4 +146,28 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT flaps.forEach((d, value) -> value.tick()); } + @Override + public void addBehaviours(List behaviours) {} + + @Override + public LazyOptional getCapability(Capability capability, Direction side) { + if (capability != CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) + return super.getCapability(capability, side); + + if (!this.cap.isPresent()) { + if (AllBlocks.BELT.has(world.getBlockState(pos.down()))) { + TileEntity teBelow = world.getTileEntity(pos.down()); + if (teBelow != null) { + T capBelow = teBelow.getCapability(capability, Direction.UP) + .orElse(null); + if (capBelow != null) { + cap = LazyOptional.of(() -> capBelow) + .cast(); + } + } + } + } + return this.cap.cast(); + } + } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java index 4d8cfdfc0..d8ed5b570 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/chute/ChuteTileEntity.java @@ -10,9 +10,9 @@ import com.simibubi.create.content.contraptions.components.fan.EncasedFanBlock; import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity; import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation; import com.simibubi.create.content.logistics.block.chute.ChuteBlock.Shape; -import com.simibubi.create.content.logistics.block.realityFunnel.BrassFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.ChuteFunnelBlock; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.BrassFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.ChuteFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.foundation.gui.widgets.InterpolatedValue; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; @@ -152,7 +152,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor return false; if (stateBelow.get(BrassFunnelBlock.FACING) != Direction.UP) return false; - ItemStack remainder = RealityFunnelBlock.tryInsert(world, pos.down(), item, simulate); + ItemStack remainder = FunnelBlock.tryInsert(world, pos.down(), item, simulate); if (!simulate) setItem(remainder); return remainder.isEmpty(); @@ -190,7 +190,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor if (AllBlocks.BRASS_FUNNEL.has(stateAbove)) { if (!stateAbove.get(BrassFunnelBlock.POWERED) && stateAbove.get(BrassFunnelBlock.FACING) == Direction.DOWN) { - ItemStack remainder = RealityFunnelBlock.tryInsert(world, pos.up(), item, simulate); + ItemStack remainder = FunnelBlock.tryInsert(world, pos.up(), item, simulate); if (remainder.isEmpty()) { if (!simulate) setItem(remainder); @@ -250,7 +250,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor continue; if (funnelState.get(ChuteFunnelBlock.PUSHING)) continue; - ItemStack remainder = RealityFunnelBlock.tryInsert(world, funnelPos, item.copy(), world.isRemote); + ItemStack remainder = FunnelBlock.tryInsert(world, funnelPos, item.copy(), world.isRemote); if (remainder.getCount() != item.getCount() && !world.isRemote) setItem(remainder); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteBeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteBeltFunnelBlock.java similarity index 81% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteBeltFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteBeltFunnelBlock.java index cfb9d5d95..8ce624cd4 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteBeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteBeltFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteChuteFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteChuteFunnelBlock.java similarity index 81% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteChuteFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteChuteFunnelBlock.java index a6a6e3f62..80bfc2baf 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteChuteFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteChuteFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java similarity index 83% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java index e537e8799..6a128adc6 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/AndesiteFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/AndesiteFunnelBlock.java @@ -1,11 +1,11 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; -public class AndesiteFunnelBlock extends RealityFunnelBlock { +public class AndesiteFunnelBlock extends FunnelBlock { public AndesiteFunnelBlock(Properties p_i48415_1_) { super(p_i48415_1_); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java similarity index 96% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java index a71f67a72..52cdc6e72 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; @@ -47,7 +47,7 @@ public abstract class BeltFunnelBlock extends HorizontalInteractionFunnelBlock { } } - public BeltFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { + public BeltFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { super(parent, p_i48377_1_); setDefaultState(getDefaultState().with(SHAPE, Shape.RETRACTED)); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java similarity index 96% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelGenerator.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java index 3c494de97..05fb003b2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BeltFunnelGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BeltFunnelGenerator.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassBeltFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassBeltFunnelBlock.java similarity index 80% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassBeltFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassBeltFunnelBlock.java index cf0ae9ef3..17dae6807 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassBeltFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassBeltFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassChuteFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassChuteFunnelBlock.java similarity index 80% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassChuteFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassChuteFunnelBlock.java index ad584afd2..cba22d4e5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassChuteFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassChuteFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java similarity index 94% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java index c036722bd..42eb7bdd3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/BrassFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/BrassFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllBlocks; @@ -12,7 +12,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BrassFunnelBlock extends RealityFunnelBlock { +public class BrassFunnelBlock extends FunnelBlock { public static final BooleanProperty POWERED = BlockStateProperties.POWERED; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelBlock.java similarity index 87% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelBlock.java index 596f94a81..f059f6861 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllShapes; import com.simibubi.create.content.logistics.block.chute.ChuteBlock; @@ -14,7 +14,7 @@ import net.minecraft.world.IWorldReader; public abstract class ChuteFunnelBlock extends HorizontalInteractionFunnelBlock { - public ChuteFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { + public ChuteFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { super(parent, p_i48377_1_); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelGenerator.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelGenerator.java similarity index 95% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelGenerator.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelGenerator.java index fb78f26e4..1bc7fa6c2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/ChuteFunnelGenerator.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/ChuteFunnelGenerator.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.foundation.data.SpecialBlockStateGen; import com.tterrag.registrate.providers.DataGenContext; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java similarity index 85% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java index 640f49b02..31684566b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelBlock.java @@ -1,7 +1,8 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import javax.annotation.Nullable; +import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.logistics.block.chute.ChuteBlock; @@ -35,9 +36,9 @@ import net.minecraft.world.IWorld; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; -public abstract class RealityFunnelBlock extends ProperDirectionalBlock implements ITE { +public abstract class FunnelBlock extends ProperDirectionalBlock implements ITE { - public RealityFunnelBlock(Properties p_i48415_1_) { + public FunnelBlock(Properties p_i48415_1_) { super(p_i48415_1_); } @@ -59,13 +60,15 @@ public abstract class RealityFunnelBlock extends ProperDirectionalBlock implemen public ActionResultType onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (hit.getFace() == getFunnelFacing(state)) { + ItemStack heldItem = player.getHeldItem(handIn); + boolean shouldntInsertItem = AllBlocks.MECHANICAL_ARM.isIn(heldItem); + + if (hit.getFace() == getFunnelFacing(state) && !shouldntInsertItem) { if (!worldIn.isRemote) withTileEntityDo(worldIn, pos, te -> { - ItemStack heldItem = player.getHeldItem(handIn) - .copy(); - ItemStack remainder = tryInsert(worldIn, pos, heldItem, false); - if (!ItemStack.areItemStacksEqual(remainder, heldItem)) + ItemStack toInsert = heldItem.copy(); + ItemStack remainder = tryInsert(worldIn, pos, toInsert, false); + if (!ItemStack.areItemStacksEqual(remainder, toInsert)) player.setHeldItem(handIn, remainder); }); return ActionResultType.SUCCESS; @@ -119,18 +122,18 @@ public abstract class RealityFunnelBlock extends ProperDirectionalBlock implemen @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return AllTileEntities.REALITY_FUNNEL.create(); + return AllTileEntities.FUNNEL.create(); } @Override public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { - return AllShapes.REALITY_FUNNEL.get(state.get(FACING)); + return AllShapes.FUNNEL.get(state.get(FACING)); } @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context) { if (context.getEntity() instanceof ItemEntity) - return AllShapes.REALITY_FUNNEL_COLLISION.get(state.get(FACING)); + return AllShapes.FUNNEL_COLLISION.get(state.get(FACING)); return getShape(state, world, pos, context); } @@ -168,7 +171,7 @@ public abstract class RealityFunnelBlock extends ProperDirectionalBlock implemen Block block = world.getBlockState(pos.offset(state.get(FACING) .getOpposite())) .getBlock(); - return !(block instanceof RealityFunnelBlock) && !(block instanceof HorizontalInteractionFunnelBlock); + return !(block instanceof FunnelBlock) && !(block instanceof HorizontalInteractionFunnelBlock); } @Nullable @@ -195,13 +198,12 @@ public abstract class RealityFunnelBlock extends ProperDirectionalBlock implemen @Nullable public static boolean isFunnel(BlockState state) { - return state.getBlock() instanceof RealityFunnelBlock - || state.getBlock() instanceof HorizontalInteractionFunnelBlock; + return state.getBlock() instanceof FunnelBlock || state.getBlock() instanceof HorizontalInteractionFunnelBlock; } @Override - public Class getTileEntityClass() { - return RealityFunnelTileEntity.class; + public Class getTileEntityClass() { + return FunnelTileEntity.class; } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelFilterSlotPositioning.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java similarity index 91% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelFilterSlotPositioning.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java index 281213b2a..add0d05e1 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelFilterSlotPositioning.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelFilterSlotPositioning.java @@ -1,8 +1,8 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.logistics.block.realityFunnel.BeltFunnelBlock.Shape; +import com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock.Shape; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.DirectionHelper; @@ -43,7 +43,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { @Override protected void rotate(BlockState state, MatrixStack ms) { - Direction facing = RealityFunnelBlock.getFunnelFacing(state); + Direction facing = FunnelBlock.getFunnelFacing(state); if (!facing.getAxis() .isVertical() @@ -76,7 +76,7 @@ public class FunnelFilterSlotPositioning extends ValueBoxTransform.Sided { @Override protected boolean isSideActive(BlockState state, Direction direction) { - Direction facing = RealityFunnelBlock.getFunnelFacing(state); + Direction facing = FunnelBlock.getFunnelFacing(state); if (facing == null) return false; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelItem.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java similarity index 89% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelItem.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java index 5a276a35f..adb57c068 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelItem.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -32,14 +32,14 @@ public class FunnelItem extends BlockItem { BlockState state = super.getStateForPlacement(ctx); if (state == null) return state; - if (!(state.getBlock() instanceof RealityFunnelBlock)) + if (!(state.getBlock() instanceof FunnelBlock)) return state; - Direction direction = state.get(RealityFunnelBlock.FACING); + Direction direction = state.get(FunnelBlock.FACING); if (!direction.getAxis() .isHorizontal()) return state; - RealityFunnelBlock block = (RealityFunnelBlock) getBlock(); + FunnelBlock block = (FunnelBlock) getBlock(); Block beltFunnelBlock = block.getEquivalentBeltFunnel(state) .getBlock(); Block chuteFunnelBlock = block.getEquivalentChuteFunnel(state) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelMovementBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java similarity index 95% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelMovementBehaviour.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java index a4521ec6e..c0cc9deef 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/FunnelMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelMovementBehaviour.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import java.util.List; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java similarity index 79% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelRenderer.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index 49955aeaf..2c49402db 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/RealityFunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; @@ -15,14 +15,14 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -public class RealityFunnelRenderer extends SmartTileEntityRenderer { +public class FunnelRenderer extends SmartTileEntityRenderer { - public RealityFunnelRenderer(TileEntityRendererDispatcher dispatcher) { + public FunnelRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override - protected void renderSafe(RealityFunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + protected void renderSafe(FunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); @@ -34,7 +34,7 @@ public class RealityFunnelRenderer extends SmartTileEntityRenderer tileEntityTypeIn) { + public FunnelTileEntity(TileEntityType tileEntityTypeIn) { super(tileEntityTypeIn); flap = new InterpolatedChasingValue().start(.25f) .target(0) @@ -51,7 +51,7 @@ public class RealityFunnelTileEntity extends SmartTileEntity { public Mode determineCurrentMode() { BlockState state = getBlockState(); - if (!RealityFunnelBlock.isFunnel(state)) + if (!FunnelBlock.isFunnel(state)) return Mode.INVALID; if (state.has(BlockStateProperties.POWERED) && state.get(BlockStateProperties.POWERED)) return Mode.PAUSED; @@ -60,7 +60,7 @@ public class RealityFunnelTileEntity extends SmartTileEntity { if (state.getBlock() instanceof ChuteFunnelBlock) return Mode.CHUTE_SIDE; - Direction facing = RealityFunnelBlock.getFunnelFacing(state); + Direction facing = FunnelBlock.getFunnelFacing(state); BlockState input = world.getBlockState(pos.offset(facing)); if (AllBlocks.CHUTE.has(input)) @@ -85,7 +85,7 @@ public class RealityFunnelTileEntity extends SmartTileEntity { public void tickAsHorizontalChuteFunnel() { if (!getBlockState().get(ChuteFunnelBlock.PUSHING)) return; - BlockPos chutePos = pos.offset(RealityFunnelBlock.getFunnelFacing(getBlockState())); + BlockPos chutePos = pos.offset(FunnelBlock.getFunnelFacing(getBlockState())); TileEntity te = world.getTileEntity(chutePos); if (!(te instanceof ChuteTileEntity)) return; @@ -97,7 +97,7 @@ public class RealityFunnelTileEntity extends SmartTileEntity { } public void tickAsVerticalChuteFunnel() { - Direction funnelFacing = RealityFunnelBlock.getFunnelFacing(getBlockState()); + Direction funnelFacing = FunnelBlock.getFunnelFacing(getBlockState()); BlockPos chutePos = pos.offset(funnelFacing); TileEntity te = world.getTileEntity(chutePos); if (!(te instanceof ChuteTileEntity)) @@ -167,7 +167,7 @@ public class RealityFunnelTileEntity extends SmartTileEntity { @Override public void addBehaviours(List behaviours) { Supplier>> direction = - Attachments.toward(() -> RealityFunnelBlock.getFunnelFacing(getBlockState()) + Attachments.toward(() -> FunnelBlock.getFunnelFacing(getBlockState()) .getOpposite()); inserting = new InsertingBehaviour(this, direction); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/HorizontalInteractionFunnelBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/HorizontalInteractionFunnelBlock.java similarity index 89% rename from src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/HorizontalInteractionFunnelBlock.java rename to src/main/java/com/simibubi/create/content/logistics/block/funnel/HorizontalInteractionFunnelBlock.java index 0e284bb4d..276a04ee5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/realityFunnel/HorizontalInteractionFunnelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/HorizontalInteractionFunnelBlock.java @@ -1,4 +1,4 @@ -package com.simibubi.create.content.logistics.block.realityFunnel; +package com.simibubi.create.content.logistics.block.funnel; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; @@ -28,9 +28,9 @@ public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock i public static final BooleanProperty POWERED = BlockStateProperties.POWERED; public static final BooleanProperty PUSHING = BooleanProperty.create("pushing"); - private BlockEntry parent; + private BlockEntry parent; - public HorizontalInteractionFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { + public HorizontalInteractionFunnelBlock(BlockEntry parent, Properties p_i48377_1_) { super(p_i48377_1_); this.parent = parent; BlockState defaultState = getDefaultState().with(PUSHING, true); @@ -48,7 +48,7 @@ public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock i @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return AllTileEntities.REALITY_FUNNEL.create(); + return AllTileEntities.FUNNEL.create(); } @Override @@ -71,7 +71,7 @@ public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock i public void onReplaced(BlockState p_196243_1_, World p_196243_2_, BlockPos p_196243_3_, BlockState p_196243_4_, boolean p_196243_5_) { if (p_196243_1_.hasTileEntity() - && (p_196243_1_.getBlock() != p_196243_4_.getBlock() && !RealityFunnelBlock.isFunnel(p_196243_4_) + && (p_196243_1_.getBlock() != p_196243_4_.getBlock() && !FunnelBlock.isFunnel(p_196243_4_) || !p_196243_4_.hasTileEntity())) { p_196243_2_.removeTileEntity(p_196243_3_); } @@ -88,7 +88,7 @@ public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock i BlockPos pos, BlockPos p_196271_6_) { if (!canStillInteract(state, world, pos)) return parent.getDefaultState() - .with(RealityFunnelBlock.FACING, state.get(HORIZONTAL_FACING)); + .with(FunnelBlock.FACING, state.get(HORIZONTAL_FACING)); return state; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index f9250cf2d..980057350 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -5,7 +5,8 @@ import javax.annotation.Nullable; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelBlock; +import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InsertingBehaviour; @@ -69,7 +70,7 @@ public abstract class ArmInteractionPoint { static boolean isInteractable(BlockState state) { return AllBlocks.DEPOT.has(state) || AllBlocks.BELT.has(state) || AllBlocks.CHUTE.has(state) - || state.getBlock() instanceof RealityFunnelBlock; + || state.getBlock() instanceof FunnelBlock; } ArmAngleTarget getTargetAngles(BlockPos armPos) { @@ -121,11 +122,12 @@ public abstract class ArmInteractionPoint { if (AllBlocks.DEPOT.has(state)) point = new Depot(); - if (AllBlocks.BELT.has(state)) + if (AllBlocks.BELT.has(state) && !(world.getBlockState(pos.up()) + .getBlock() instanceof BeltTunnelBlock)) point = new Belt(); if (AllBlocks.CHUTE.has(state)) point = new Chute(); - if (state.getBlock() instanceof RealityFunnelBlock) + if (state.getBlock() instanceof FunnelBlock) point = new Funnel(); if (point != null) { @@ -193,7 +195,7 @@ public abstract class ArmInteractionPoint { @Override Vec3d getInteractionPositionVector() { return VecHelper.getCenterOf(pos) - .add(new Vec3d(RealityFunnelBlock.getFunnelFacing(state) + .add(new Vec3d(FunnelBlock.getFunnelFacing(state) .getDirectionVec()).scale(.5f)); } @@ -209,7 +211,7 @@ public abstract class ArmInteractionPoint { @Override Direction getInteractionDirection() { - return RealityFunnelBlock.getFunnelFacing(state) + return FunnelBlock.getFunnelFacing(state) .getOpposite(); } @@ -226,7 +228,7 @@ public abstract class ArmInteractionPoint { @Override boolean isValid(BlockState state) { - return state.getBlock() instanceof RealityFunnelBlock; + return state.getBlock() instanceof FunnelBlock; } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java index 1a48f106e..bedc6d494 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/RedstoneLinkBlock.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.redstone; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.wrench.IWrenchable; -import com.simibubi.create.content.logistics.block.realityFunnel.RealityFunnelBlock; +import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.utility.Iterate; @@ -165,7 +165,7 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE NonNullUnaryOperator> funnel( + public static NonNullUnaryOperator> funnel( String type, ResourceLocation particleTexture) { return b -> { return b.blockstate((c, p) -> { @@ -95,7 +96,7 @@ public class BuilderTransformers { .rotationY(state.get(BeltTunnelBlock.HORIZONTAL_AXIS) == Axis.X ? 0 : 90) .build(); })) - .item() + .item(BeltTunnelItem::new) .model((c, p) -> { String id = type + "_tunnel"; p.withExistingParent("item/" + id, p.modLoc("block/belt_tunnel/item")) diff --git a/src/main/resources/assets/create/textures/block/andesite_tunnel.png b/src/main/resources/assets/create/textures/block/andesite_tunnel.png index 36f1f6a14..6c6c41b10 100644 Binary files a/src/main/resources/assets/create/textures/block/andesite_tunnel.png and b/src/main/resources/assets/create/textures/block/andesite_tunnel.png differ