From 9501a0ed94dd0817c055272fb7706552543a9e2e Mon Sep 17 00:00:00 2001 From: lothrazar Date: Sat, 19 Oct 2024 21:44:00 -0700 Subject: [PATCH] adding comparator support to more blocks --- build.gradle | 2 ++ .../com/lothrazar/cyclic/base/TileEntityBase.java | 15 +++++++++++++++ .../block/collectitem/BlockItemCollector.java | 11 +++++++++++ .../block/collectitem/TileItemCollector.java | 1 + .../com/lothrazar/cyclic/block/dice/TileDice.java | 2 +- .../block/enderitemshelf/BlockItemShelf.java | 14 ++++++++++++++ .../cyclic/block/fishing/BlockFisher.java | 12 ++++++++++++ .../cyclic/block/fishing/TileFisher.java | 1 + .../cyclic/block/forester/BlockForester.java | 11 +++++++++++ .../cyclic/block/forester/TileForester.java | 1 + .../block/generatorfluid/BlockGeneratorFluid.java | 13 +++++++++++++ .../block/generatorfood/BlockGeneratorFood.java | 13 +++++++++++++ .../block/generatorfood/TileGeneratorFood.java | 1 + .../block/generatorfuel/BlockGeneratorFuel.java | 13 +++++++++++++ .../block/generatorfuel/TileGeneratorFuel.java | 1 + .../block/generatoritem/BlockGeneratorDrops.java | 13 +++++++++++++ .../block/generatoritem/TileGeneratorDrops.java | 3 +-- .../block/generatorpeat/BlockGeneratorPeat.java | 13 +++++++++++++ .../block/generatorpeat/TileGeneratorPeat.java | 1 + .../cyclic/block/hopper/BlockSimpleHopper.java | 12 ++++++++++++ .../cyclic/block/hopper/TileSimpleHopper.java | 5 +++-- update.json | 2 +- 22 files changed, 154 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 0954c7173..54ecc349b 100644 --- a/build.gradle +++ b/build.gradle @@ -97,6 +97,8 @@ dependencies { // optional dependencies & mods for testing compat + implementation fg.deobf("curse.maven:jade-324717:3910873") + implementation fg.deobf("curse.maven:mantle-74924:3482897") implementation fg.deobf("curse.maven:tinkers-construct-74072:3482903") implementation fg.deobf("curse.maven:cucumber-272335:3507886") diff --git a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java index 4c35874c1..2307ae2b8 100644 --- a/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java +++ b/src/main/java/com/lothrazar/cyclic/base/TileEntityBase.java @@ -523,6 +523,10 @@ public void setFluid(FluidStack fluid) {} @Deprecated @Override public int getSizeInventory() { + IItemHandler invo = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + if (invo != null) { + return invo.getSlots(); + } return 0; } @@ -535,6 +539,13 @@ public boolean isEmpty() { @Deprecated @Override public ItemStack getStackInSlot(int index) { + IItemHandler invo = this.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null); + try { + if (invo != null && index < invo.getSlots()) { + return invo.getStackInSlot(index); + } + } + catch (Exception e) {} return ItemStack.EMPTY; } @@ -609,4 +620,8 @@ public boolean getBlockStateVertical() { return this.getBlockState().get(BlockStateProperties.FACING).getAxis().isVertical(); return false; } + + public void updateComparatorOutputLevel() { + world.updateComparatorOutputLevel(pos, this.getBlockState().getBlock()); + } } diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java index 025209d86..791bab88b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/BlockItemCollector.java @@ -9,6 +9,7 @@ import net.minecraft.block.SoundType; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -25,6 +26,16 @@ public BlockItemCollector(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) { if (entity != null) { diff --git a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java index 551ad4217..2c9a5365f 100644 --- a/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java +++ b/src/main/java/com/lothrazar/cyclic/block/collectitem/TileItemCollector.java @@ -81,6 +81,7 @@ public void tick() { break; } remainder = inventory.insertItem(i, remainder, false); + updateComparatorOutputLevel(); } stackEntity.setItem(remainder); if (remainder.isEmpty()) { diff --git a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java index cde4bbbaa..22f2a9c38 100644 --- a/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java +++ b/src/main/java/com/lothrazar/cyclic/block/dice/TileDice.java @@ -44,7 +44,7 @@ public void startSpinning() { public void tick() { if (this.timer == 0) { this.spinningIfZero = 1; - world.updateComparatorOutputLevel(pos, this.getBlockState().getBlock()); + updateComparatorOutputLevel(); } else { this.timer--; diff --git a/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java index 83686fc88..df798b885 100644 --- a/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java +++ b/src/main/java/com/lothrazar/cyclic/block/enderitemshelf/BlockItemShelf.java @@ -14,6 +14,7 @@ import net.minecraft.block.BlockState; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.state.StateContainer; @@ -35,6 +36,16 @@ public BlockItemShelf(Properties properties) { super(properties.hardnessAndResistance(0.8F).notSolid()); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { ClientRegistry.bindTileEntityRenderer(TileRegistry.ENDER_ITEM_SHELF.get(), ItemShelfRenderer::new); @@ -89,6 +100,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos //try to insert boolean oldEmpty = shelfStack.isEmpty(); ItemStack remaining = shelf.inventory.insertItem(slot, heldItem, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); if (remaining.isEmpty() || remaining.getCount() != shelfStack.getCount()) { player.setHeldItem(hand, remaining); player.swingArm(hand); @@ -102,6 +114,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos //withdraw direct to players empty hand int q = player.isCrouching() ? 1 : 64; ItemStack retrieved = shelf.inventory.extractItem(slot, q, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); player.setHeldItem(hand, retrieved); player.swingArm(hand); } @@ -114,6 +127,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos player.setHeldItem(hand, forPlayer); player.swingArm(hand); shelf.inventory.insertItem(slot, forShelf, false); + world.updateComparatorOutputLevel(pos, shelf.getBlockState().getBlock()); } return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java index 5d6935d8b..82d2c0a07 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/BlockFisher.java @@ -8,10 +8,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.fluid.FluidState; +import net.minecraft.inventory.container.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockDisplayReader; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; import net.minecraftforge.fml.client.registry.ClientRegistry; public class BlockFisher extends BlockBase { @@ -21,6 +23,16 @@ public BlockFisher(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState) { return true; diff --git a/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java b/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java index 1b9525309..9f9b164b1 100644 --- a/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java +++ b/src/main/java/com/lothrazar/cyclic/block/fishing/TileFisher.java @@ -116,6 +116,7 @@ public void tick() { catch (Exception e) { ModCyclic.LOGGER.error("Fishing Block: Loot table failed", e); } + updateComparatorOutputLevel(); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java index cf3bd23be..da5aaabab 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/BlockForester.java @@ -8,6 +8,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; import net.minecraft.entity.LivingEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; @@ -24,6 +25,16 @@ public BlockForester(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public void registerClient() { ClientRegistry.bindTileEntityRenderer(TileRegistry.FORESTER, RenderForester::new); diff --git a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java index 17aafba3a..d160507fa 100644 --- a/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java +++ b/src/main/java/com/lothrazar/cyclic/block/forester/TileForester.java @@ -114,6 +114,7 @@ public void tick() { else if (this.isSapling(dropMe)) { ActionResultType result = TileEntityBase.rightClickBlock(fakePlayer, world, targetPos, Hand.OFF_HAND, Direction.DOWN); if (result == ActionResultType.CONSUME) { + updateComparatorOutputLevel(); //ok then DRAIN POWER energy.extractEnergy(cost, false); } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java index 57c92b3d2..e7924aa2e 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfluid/BlockGeneratorFluid.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFluid extends BlockBase { @@ -21,6 +24,16 @@ public BlockGeneratorFluid(Properties properties) { this.setHasFluidInteract(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java b/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java index 39c50bcae..dd6ad5d2b 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfood/BlockGeneratorFood.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFood extends BlockBase { @@ -20,6 +23,16 @@ public BlockGeneratorFood(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java b/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java index 032a76b25..94d133a42 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfood/TileGeneratorFood.java @@ -92,6 +92,7 @@ private void tryConsumeFuel() { this.burnTimeMax = burnTimeTicks; this.burnTime = this.burnTimeMax; stack.shrink(1); + updateComparatorOutputLevel(); //nether items, mob drops // lava fluid //exp fluid diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java index ea7a31dc4..193f5668d 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/BlockGeneratorFuel.java @@ -7,10 +7,13 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorFuel extends BlockBase { @@ -20,6 +23,16 @@ public BlockGeneratorFuel(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(BlockStateProperties.FACING).add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java index f448ed960..d3323c1ea 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorfuel/TileGeneratorFuel.java @@ -97,6 +97,7 @@ private void tryConsumeFuel() { else { stack.shrink(1); } + updateComparatorOutputLevel(); } } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java b/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java index 3a07e99e7..32a3b3f42 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatoritem/BlockGeneratorDrops.java @@ -7,9 +7,12 @@ import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorDrops extends BlockBase { @@ -19,6 +22,16 @@ public BlockGeneratorDrops(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(LIT); diff --git a/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java b/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java index 4e1b1283a..aa78ab088 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatoritem/TileGeneratorDrops.java @@ -1,6 +1,5 @@ package com.lothrazar.cyclic.block.generatoritem; -import com.lothrazar.cyclic.ModCyclic; import com.lothrazar.cyclic.base.TileEntityBase; import com.lothrazar.cyclic.block.battery.TileBattery; import com.lothrazar.cyclic.capability.CustomEnergyStorage; @@ -106,7 +105,7 @@ private void findMatchingRecipe() { this.burnTime = this.burnTimeMax; this.burnPerTick = this.currentRecipe.getRfpertick(); this.inputSlots.extractItem(0, 1, false); - ModCyclic.LOGGER.info("found genrecipe" + currentRecipe.getId()); + updateComparatorOutputLevel(); return; } } diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java index e8284b574..4d2e34013 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/BlockGeneratorPeat.java @@ -5,9 +5,12 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.gui.ScreenManager; +import net.minecraft.inventory.container.Container; import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; public class BlockGeneratorPeat extends BlockBase { @@ -16,6 +19,16 @@ public BlockGeneratorPeat(Properties properties) { this.setHasGui(); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override public boolean hasTileEntity(BlockState state) { return true; diff --git a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java index 09393a20d..7187e4899 100644 --- a/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java +++ b/src/main/java/com/lothrazar/cyclic/block/generatorpeat/TileGeneratorPeat.java @@ -109,6 +109,7 @@ public void tick() { fuelRate = peat.getPeatFuelValue(); inventory.extractItem(0, 1, false); this.timer = BURNTIME; + updateComparatorOutputLevel(); } } } diff --git a/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java index 6bd3bd7c0..8a674acb0 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopper/BlockSimpleHopper.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.inventory.container.Container; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer; @@ -16,6 +17,7 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; @SuppressWarnings("deprecation") public class BlockSimpleHopper extends BlockBase { @@ -26,6 +28,16 @@ public BlockSimpleHopper(Properties properties) { super(properties.hardnessAndResistance(1.3F)); } + @Override + public boolean hasComparatorInputOverride(BlockState state) { + return true; + } + + @Override + public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { + return Container.calcRedstone(worldIn.getTileEntity(pos)); + } + @Override protected void fillStateContainer(StateContainer.Builder builder) { builder.add(FACING); diff --git a/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java b/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java index 8c6ad13d2..556bc8f87 100644 --- a/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java +++ b/src/main/java/com/lothrazar/cyclic/block/hopper/TileSimpleHopper.java @@ -1,7 +1,6 @@ package com.lothrazar.cyclic.block.hopper; import com.lothrazar.cyclic.base.TileEntityBase; -import com.lothrazar.cyclic.block.hopperfluid.BlockFluidHopper; import com.lothrazar.cyclic.registry.TileRegistry; import java.util.List; import net.minecraft.block.BlockState; @@ -55,9 +54,10 @@ public void tick() { } this.tryPullFromWorld(pos.offset(Direction.UP)); this.tryExtract(inventory, Direction.UP, getFlow(), null); - Direction exportToSide = this.getBlockState().get(BlockFluidHopper.FACING); + Direction exportToSide = this.getBlockState().get(BlockSimpleHopper.FACING); this.moveItemToCompost(exportToSide, inventory); this.moveItems(exportToSide, getFlow(), inventory); + updateComparatorOutputLevel(); } public int getFlow() { @@ -74,6 +74,7 @@ private void tryPullFromWorld(BlockPos center) { if (remainder.isEmpty()) { stackEntity.remove(); } + updateComparatorOutputLevel(); } } diff --git a/update.json b/update.json index 1b71188be..96d83aba7 100644 --- a/update.json +++ b/update.json @@ -81,6 +81,6 @@ ,"1.5.22":"Fix #2351 advanced crafting stick not opening. " ,"1.5.23":"Growth enchantment now uses the same logic as Sprinkler & Terra Soil (only minecraft:crops or minecraft::saplings can grow, respect IGrowable::canUseBonemeal). New gloomIgnored config Gloom enchant (cyclic:curse) to ignore and not use these effects #2217 #2325. Fix Soundproofing block not muting Mekanism sounds #2389 (for example Precision Sawmill and others - you may need four or more soundproofing blocks for the desired effect). Patch an edge-case where User might drop items on the ground. New config [cyclic.blocks.soundproofing] radius = 6 to control the area. Fix item cable routing #2245 #2230. New config under [cyclic.blocks] wireless_transfer_dimensional = true allowing transfer nodes to connect across dimensions #1913. Balance recipe changes for #2372. Balance changes made for Excavate enchant it will no longer trigger if the tool is not 'mineable' effective for example axe on dirt. New feature for Excavate enchant #2116 it will not trigger on anything matching the block data-tag 'cyclic:ignored/excavate'. [Backported changes from mc1.20.1] #2182 candle model assets; Block Breaker no longer tries (and fails) to mine liquid source blocks; Block Randomizer use wireframe rendering only of non-air instead of solid shading; Glistering & Corrupted chorus only restores 1 food-unit down from 3; a few recipes tweaked/backported to match mc1.20.1+, ported crafttweaker zenscript support for generator_fluid and generator_item; backported item data tags for use in recipes for example forge:vines, forge:sandstone, forge:mushrooms " ,"1.5.24":"Fixed bug in the item cyclic:offset_scepter #2427. Tweaked block model visuals of the Transfer Nodes. Fix Mattock not saving contents of Shulker Boxes when mined #2411. " - ,"":"Fluid collector will now place air and scoop up the fluid if the itemslot is empty. New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). Backported machine feature 'Preview Outline' mode on machines that already have the button. Backported cable (fluid & energy) buffer and flow speed configs from 1.20.1 " + ,"":"Some blocks allow minecraft:comparator to pull a redstone signal based on inventory contents: Wooden Hopper, Item Collector, Forester, Item Shelf, . Fluid collector will now place air and scoop up the fluid if the itemslot is empty. New feature: some machines can now be placed facing Up or Down vertically for convenience (harvester, forester, miner, item collector, fluid collector, dropper). Backported machine feature 'Preview Outline' mode on machines that already have the button. Backported cable (fluid & energy) buffer and flow speed configs from 1.20.1 " } }