From 11993d575ba386ec5627c46d5ce550624759497d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Fri, 24 Jun 2016 10:31:03 +0200 Subject: [PATCH] Alloy furnace - Basic comparator output --- TODO.txt | 1 - .../mmm/tech/base/TBAlloyFurnaceBlock.java | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index 45a4a36..96fc164 100644 --- a/TODO.txt +++ b/TODO.txt @@ -41,7 +41,6 @@ materials.ores No Tin materials.ores No Zinc ------------------------------------------------------------------------------------------------------- tech.base No Alloy furnace - -> comparator output -> search recipe -> crafting recipe -> I18n diff --git a/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java b/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java index 6171b8d..742f923 100644 --- a/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java +++ b/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java @@ -22,6 +22,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; +import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -330,7 +331,6 @@ public class TBAlloyFurnaceBlock { if ( !TBAlloyFurnaceBlock.keepInventory ) { final TileEntity tileEntity = worldIn.getTileEntity( pos ); - if ( tileEntity instanceof TBAlloyFurnaceTileEntity ) { final TBAlloyFurnaceTileEntity afte = (TBAlloyFurnaceTileEntity) tileEntity; afte.cancelAlloying( ); @@ -338,9 +338,30 @@ public class TBAlloyFurnaceBlock InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel ); InventoryHelper.dropInventoryItems( worldIn , pos , afte.output ); } + worldIn.updateComparatorOutputLevel(pos, this); } super.breakBlock( worldIn , pos , state ); } + + // ************************************************************************************************* + // COMPARATORS + // ************************************************************************************************* + + public boolean hasComparatorInputOverride( IBlockState state ) + { + return true; + } + + + public int getComparatorInputOverride( IBlockState blockState , World worldIn , BlockPos pos ) + { + TileEntity te = worldIn.getTileEntity( pos ); + if ( ! ( te instanceof TBAlloyFurnaceTileEntity ) ) { + return 0; + } + return Container.calcRedstoneFromInventory( ( (TBAlloyFurnaceTileEntity) te ).output ); + } + }