diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index e02eddf6d..6acf27fc6 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -175,6 +175,7 @@ public enum AllBlocks { VERTICAL_FUNNEL(new FunnelBlock.Vertical()), BELT_TUNNEL(new BeltTunnelBlock()), BELT_TUNNEL_FLAP(new RenderUtilityBlock()), + BELT_TUNNEL_INDICATOR(new RenderUtilityBlock()), ENTITY_DETECTOR(new BeltObserverBlock()), PULSE_REPEATER(new PulseRepeaterBlock()), FLEXPEATER(new FlexpeaterBlock()), diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index d454cd82e..d4d1c93ab 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -42,9 +42,9 @@ import net.minecraftforge.registries.IForgeRegistry; public enum AllItems { __MATERIALS__(), + ANDESITE_ALLOY_CUBE(ingredient()), COPPER_INGOT(ingredient()), ZINC_CUBE(ingredient()), - ANDESITE_ALLOY_CUBE(ingredient()), BRASS_CUBE(ingredient()), COPPER_NUGGET(ingredient()), ZINC_NUGGET(ingredient()), diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java index 917704cb4..716a0c516 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/AirCurrent.java @@ -255,7 +255,7 @@ public class AirCurrent { continue; World world = belt.getWorld(); - controller.getInventory().forEachWithin(belt.index + .5f, .5f, (transported) -> { + controller.getInventory().forEachWithin(belt.index + .5f, .51f, (transported) -> { InWorldProcessing.spawnParticlesForProcessing(world, controller.getInventory().getVectorForOffset(transported.beltPosition), processingType); if (world.isRemote) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java index 2f0b5f82d..0a3cf7144 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java @@ -192,7 +192,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IHaveNoBlockIte return false; if (worldIn.isRemote) return true; - controllerBelt.getInventory().forEachWithin(belt.index, .75f, (transportedItemStack) -> { + controllerBelt.getInventory().forEachWithin(belt.index + .5f, .55f, (transportedItemStack) -> { player.inventory.placeItemBackInInventory(worldIn, transportedItemStack.stack); return Collections.emptyList(); }); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltInventory.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltInventory.java index a754c3808..2860414d2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltInventory.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltInventory.java @@ -103,6 +103,7 @@ public class BeltInventory { float limitedMovement = beltMovementPositive ? Math.min(movement, diffToEnd) : Math.max(movement, diffToEnd); + float nextOffset = current.beltPosition + limitedMovement; if (!onClient) { // Don't move if belt attachments want to continue processing if (segmentBefore != -1 && current.locked) { @@ -122,10 +123,8 @@ public class BeltInventory { // See if any new belt processing catches the item int upcomingSegment = (int) (current.beltPosition + (beltMovementPositive ? .5f : -.5f)); - for (int segment = upcomingSegment; beltMovementPositive - ? segment + .5f <= current.beltPosition + limitedMovement - : segment + .5f >= current.beltPosition + limitedMovement; segment += beltMovementPositive ? 1 - : -1) { + for (int segment = upcomingSegment; beltMovementPositive ? segment + .5f <= nextOffset + : segment + .5f >= nextOffset; segment += beltMovementPositive ? 1 : -1) { BeltTileEntity beltSegment = getBeltSegment(segmentBefore); if (beltSegment == null) break; @@ -140,11 +139,16 @@ public class BeltInventory { } } - // Client: Belt tunnel flaps - if (onClient) { + // Belt tunnels + { int seg1 = (int) current.beltPosition; - int seg2 = (int) (current.beltPosition + limitedMovement); + int seg2 = (int) nextOffset; + if (!beltMovementPositive && nextOffset == 0) + seg2 = -1; if (seg1 != seg2) { + if (stuckAtTunnel(seg2, current.stack, belt.getMovementFacing())) { + continue; + } flapTunnel(seg1, belt.getMovementFacing(), false); flapTunnel(seg2, belt.getMovementFacing().getOpposite(), true); } @@ -247,6 +251,44 @@ public class BeltInventory { } + private boolean stuckAtTunnel(int offset, ItemStack stack, Direction movementDirection) { + BlockPos pos = getPositionForOffset(offset).up(); + if (!AllBlocks.BELT_TUNNEL.typeOf(belt.getWorld().getBlockState(pos))) + return false; + TileEntity te = belt.getWorld().getTileEntity(pos); + if (te == null || !(te instanceof BeltTunnelTileEntity)) + return false; + + Direction flapFacing = movementDirection; + if (flapFacing.getAxis() == Axis.X) + flapFacing = flapFacing.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; + } + private void flapTunnel(int offset, Direction side, boolean inward) { if (belt.getBlockState().get(BeltBlock.SLOPE) != Slope.HORIZONTAL) return; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java index b80e88485..6df2fc7fa 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java @@ -159,6 +159,7 @@ public class BeltTileEntity extends KineticTileEntity { @Override public void read(CompoundNBT compound) { + super.read(compound); trackerUpdateTag = compound; controller = NBTUtil.readBlockPos(compound.getCompound("Controller")); color = compound.getInt("Color"); @@ -167,7 +168,6 @@ public class BeltTileEntity extends KineticTileEntity { if (isController()) getInventory().read(compound.getCompound("Inventory")); - super.read(compound); } public void applyColor(DyeColor colorIn) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelBlock.java index 4ffca89aa..db4d4b334 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelBlock.java @@ -1,5 +1,9 @@ package com.simibubi.create.modules.contraptions.relays.belt; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.simibubi.create.AllBlocks; import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.utility.Lang; @@ -107,20 +111,47 @@ public class BeltTunnelBlock extends Block implements IWithTileEntity 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 static BlockState getTunnelState(IBlockReader reader, BlockPos pos) { @@ -159,6 +190,12 @@ public class BeltTunnelBlock extends Block implements IWithTileEntity flaps; + public HashMap syncedFlaps; private LazyOptional cap = LazyOptional.empty(); private boolean initialize; @@ -33,6 +35,7 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT public BeltTunnelTileEntity() { super(AllTileEntities.BELT_TUNNEL.type); flaps = new HashMap<>(); + syncedFlaps = new HashMap<>(); initialize = true; } @@ -62,6 +65,41 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT cap.invalidate(); } + @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); @@ -86,7 +124,6 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT public void initFlaps() { if (!world.isRemote) { sendData(); - return; } initialize = false; @@ -126,10 +163,10 @@ public class BeltTunnelTileEntity extends SyncedTileEntity implements ITickableT @Override public void tick() { - if (!world.isRemote) - return; if (initialize) initFlaps(); + if (!world.isRemote) + return; flaps.forEach((d, value) -> value.tick()); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelTileEntityRenderer.java index 40621208c..3e070144f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTunnelTileEntityRenderer.java @@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.relays.belt; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.block.BlockState; @@ -19,7 +20,9 @@ public class BeltTunnelTileEntityRenderer extends TileEntityRendererFast getInventory(); - - public void setInventory(LazyOptional inventory); - - default boolean findNewInventory() { - BlockPos invPos = getInventoryPos(); - World world = getWorld(); - - if (!world.isBlockPresent(invPos)) - return false; - BlockState invState = world.getBlockState(invPos); - - if (!invState.hasTileEntity()) - return false; - TileEntity invTE = world.getTileEntity(invPos); - if (invTE == null) - return false; - - LazyOptional inventory = invTE.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); - setInventory(inventory); - if (inventory.isPresent()) { - return true; - } - - return false; - } - - public default void neighborChanged() { - boolean hasInventory = getInventory().isPresent(); - if (!hasInventory) { - findNewInventory(); - } - } - -} diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/RedstoneLinkTileEntity.java b/src/main/java/com/simibubi/create/modules/logistics/block/RedstoneLinkTileEntity.java index b7ccda318..2db7812e6 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/RedstoneLinkTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/RedstoneLinkTileEntity.java @@ -44,13 +44,13 @@ public class RedstoneLinkTileEntity extends SmartTileEntity { @Override public void addBehavioursDeferred(List behaviours) { - if (slots == null) - createSlotPositioning(); createLink(); behaviours.add(link); } protected void createLink() { + if (slots == null) + createSlotPositioning(); if (transmitter) link = LinkBehaviour.transmitter(this, this::getSignal); else diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/belts/ExtractorForBeltsBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/belts/ExtractorForBeltsBlock.java new file mode 100644 index 000000000..5b1f9f3bf --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/logistics/block/belts/ExtractorForBeltsBlock.java @@ -0,0 +1,75 @@ +package com.simibubi.create.modules.logistics.block.belts; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; +import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; +import com.simibubi.create.foundation.behaviour.inventory.ExtractingBehaviour; +import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; +import com.simibubi.create.modules.contraptions.relays.belt.TransportedItemStack; +import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState; +import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.IBeltAttachment; + +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; + +public abstract class ExtractorForBeltsBlock extends AttachedLogisticalBlock implements IBeltAttachment { + + @Override + public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + onAttachmentPlaced(worldIn, pos, state); + } + + @Override + public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + onAttachmentRemoved(worldIn, pos, state); + if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { + worldIn.removeTileEntity(pos); + } + } + + @Override + public BlockPos getBeltPositionForAttachment(IWorld world, BlockPos pos, BlockState state) { + return pos.offset(getBlockFacing(state)); + } + + @Override + public List getPotentialAttachmentPositions(IWorld world, BlockPos pos, BlockState beltState) { + return Arrays.asList(Direction.values()).stream().filter(d -> d != Direction.UP).map(pos::offset) + .collect(Collectors.toList()); + } + + public boolean startProcessingItem(BeltTileEntity te, TransportedItemStack transported, BeltAttachmentState state) { + BlockPos pos = state.attachmentPos; + World world = te.getWorld(); + ItemStack stack = transported.stack; + + FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); + ExtractingBehaviour extracting = TileEntityBehaviour.get(world, pos, ExtractingBehaviour.TYPE); + + if (extracting == null) + return false; + if (filtering != null && (!filtering.test(stack) || stack.getCount() < filtering.getFilter().getCount())) + return false; + + return true; + } + + public boolean processItem(BeltTileEntity te, TransportedItemStack transported, BeltAttachmentState state) { + BlockPos pos = state.attachmentPos; + World world = te.getWorld(); + ExtractingBehaviour extracting = TileEntityBehaviour.get(world, pos, ExtractingBehaviour.TYPE); + + if (extracting == null) + return false; + extracting.extract(); + return false; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelBlock.java b/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelBlock.java index 6959070f5..0685b1ab6 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelBlock.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelBlock.java @@ -10,10 +10,11 @@ import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.B import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.IBeltAttachment; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.TransportedItemStack; -import com.simibubi.create.modules.logistics.block.IInventoryManipulator; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.state.BooleanProperty; @@ -26,7 +27,6 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; -import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class FunnelBlock extends AttachedLogisticalBlock @@ -55,6 +55,22 @@ public class FunnelBlock extends AttachedLogisticalBlock protected boolean isVertical() { return false; } + + @Override + public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { + if (worldIn.isRemote) + return; + if (!(entityIn instanceof ItemEntity)) + return; + ItemEntity itemEntity = (ItemEntity) entityIn; + withTileEntityDo(worldIn, pos, te -> { + ItemStack remainder = te.tryToInsert(itemEntity.getItem()); + if (remainder.isEmpty()) + itemEntity.remove(); + if (remainder.getCount() < itemEntity.getItem().getCount()) + itemEntity.setItem(remainder); + }); + } @Override protected BlockState getVerticalDefaultState() { @@ -95,21 +111,6 @@ public class FunnelBlock extends AttachedLogisticalBlock @Override public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { onAttachmentPlaced(worldIn, pos, state); - updateObservedInventory(state, worldIn, pos); - } - - @Override - public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { - if (!neighbor.equals(pos.offset(state.get(HORIZONTAL_FACING)))) - return; - updateObservedInventory(state, world, pos); - } - - private void updateObservedInventory(BlockState state, IWorldReader world, BlockPos pos) { - IInventoryManipulator te = (IInventoryManipulator) world.getTileEntity(pos); - if (te == null) - return; - te.neighborChanged(); } @Override diff --git a/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelTileEntity.java b/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelTileEntity.java index dcaffaa09..e6aab658d 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/logistics/block/belts/FunnelTileEntity.java @@ -7,10 +7,10 @@ import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour.SlotPositioning; +import com.simibubi.create.foundation.behaviour.inventory.InsertingBehaviour; +import com.simibubi.create.foundation.behaviour.inventory.InventoryManagementBehaviour.Attachments; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.VecHelper; -import com.simibubi.create.modules.contraptions.relays.belt.ItemHandlerBeltSegment; -import com.simibubi.create.modules.logistics.block.IInventoryManipulator; import com.simibubi.create.modules.logistics.block.extractor.ExtractorBlock; import net.minecraft.item.ItemStack; @@ -18,30 +18,22 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.ItemHandlerHelper; -public class FunnelTileEntity extends SmartTileEntity implements ITickableTileEntity, IInventoryManipulator { +public class FunnelTileEntity extends SmartTileEntity { private static FilteringBehaviour.SlotPositioning slots; private FilteringBehaviour filtering; - - private LazyOptional inventory; - protected boolean waitingForInventorySpace; + private InsertingBehaviour inserting; private ItemStack justEaten; public FunnelTileEntity() { super(AllTileEntities.BELT_FUNNEL.type); - inventory = LazyOptional.empty(); } @Override @@ -50,22 +42,12 @@ public class FunnelTileEntity extends SmartTileEntity implements ITickableTileEn createSlotPositioning(); filtering = new FilteringBehaviour(this).withCallback(this::filterChanged).withSlotPositioning(slots); behaviours.add(filtering); + inserting = new InsertingBehaviour(this, + Attachments.toward(() -> AttachedLogisticalBlock.getBlockFacing(getBlockState()))); + behaviours.add(inserting); } public void filterChanged(ItemStack stack) { - neighborChanged(); - } - - @Override - public void read(CompoundNBT compound) { - waitingForInventorySpace = compound.getBoolean("Waiting"); - super.read(compound); - } - - @Override - public CompoundNBT write(CompoundNBT compound) { - compound.putBoolean("Waiting", waitingForInventorySpace); - return super.write(compound); } @Override @@ -80,67 +62,29 @@ public class FunnelTileEntity extends SmartTileEntity implements ITickableTileEn @Override public void readClientUpdate(CompoundNBT tag) { super.readClientUpdate(tag); - if (!waitingForInventorySpace) - neighborChanged(); if (tag.contains("Nom")) justEaten = ItemStack.read(tag.getCompound("Nom")); } - @Override - public BlockPos getInventoryPos() { - return pos.offset(getBlockState().get(BlockStateProperties.HORIZONTAL_FACING)); - } - - @Override - public LazyOptional getInventory() { - return inventory; - } - @Override public void tick() { + super.tick(); if (world.isRemote && justEaten != null) { spawnParticles(justEaten); justEaten = null; } } - @Override - public void initialize() { - neighborChanged(); - super.initialize(); - } - - @Override - public void setInventory(LazyOptional inventory) { - this.inventory = inventory; - } - - @Override - public void neighborChanged() { - IInventoryManipulator.super.neighborChanged(); - waitingForInventorySpace = false; - if (!world.isRemote) - sendData(); - } - public ItemStack tryToInsert(ItemStack stack) { - if (!inventory.isPresent()) - return stack; - if (waitingForInventorySpace && !(inventory.orElse(null) instanceof ItemHandlerBeltSegment)) - return stack; if (!filtering.test(stack)) return stack; - IItemHandler inv = inventory.orElse(null); - ItemStack inserted = stack.copy(); - ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, inserted, false); - waitingForInventorySpace = true; + ItemStack remainder = inserting.insert(stack.copy(), false); if (remainder.isEmpty()) { if (!world.isRemote) world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, .125f, 1f); justEaten = stack.copy(); - waitingForInventorySpace = false; } sendData(); diff --git a/src/main/resources/assets/create/blockstates/belt_tunnel_indicator.json b/src/main/resources/assets/create/blockstates/belt_tunnel_indicator.json new file mode 100644 index 000000000..387520796 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/belt_tunnel_indicator.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "create:block/belt_tunnel/indicator" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/belt_tunnel/indicator.json b/src/main/resources/assets/create/models/block/belt_tunnel/indicator.json new file mode 100644 index 000000000..1558c2d43 --- /dev/null +++ b/src/main/resources/assets/create/models/block/belt_tunnel/indicator.json @@ -0,0 +1,22 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "textures": { + "0": "create:block/belt_tunnel", + "particle": "create:block/belt_tunnel" + }, + "elements": [ + { + "from": [6, 10, 16], + "to": [10, 14, 17], + "faces": { + "north": {"uv": [4.75, 0, 5.75, 1], "texture": "#0"}, + "east": {"uv": [5.5, 0, 5.75, 1], "texture": "#0"}, + "south": {"uv": [4.75, 0, 5.75, 1], "texture": "#0"}, + "west": {"uv": [4.75, 0, 5, 1], "texture": "#0"}, + "up": {"uv": [4.75, 0, 5, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [4.75, 0, 5, 1], "rotation": 90, "texture": "#0"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/block/belt_tunnel.png b/src/main/resources/assets/create/textures/block/belt_tunnel.png index 8f2cd7010..e4272a45f 100644 Binary files a/src/main/resources/assets/create/textures/block/belt_tunnel.png and b/src/main/resources/assets/create/textures/block/belt_tunnel.png differ