diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index da42cb995..a8ae95d76 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -25,8 +25,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; @@ -240,8 +238,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB @Override public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){ TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IInventory){ - return Container.calcRedstoneFromInventory((IInventory)tile); + if(tile instanceof TileEntityBase){ + return ((TileEntityBase)tile).getComparatorStrength(); } return 0; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index c0bb51a32..d0dca5218 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -113,7 +113,7 @@ public final class InitBooklet{ crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTALS).setNoText()); crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText()); chaptersIntroduction[5] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial(); - chaptersIntroduction[4] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageCrafting(1, BlockCrafting.recipeCoalGen).setWildcard().addTextReplacement("", TileEntityCoalGenerator.PRODUCE)); + chaptersIntroduction[4] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageTextOnly(1).addTextReplacement("", TileEntityCoalGenerator.PRODUCE), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText()); ArrayList empowererPages = new ArrayList(); empowererPages.addAll(Arrays.asList(new PageTextOnly(1), new PagePicture(2, "pageEmpowerer", 137), new PageCrafting(3, BlockCrafting.recipeEmpowerer), new PageCrafting(4, BlockCrafting.recipeDisplayStand))); for(int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++){ @@ -200,7 +200,7 @@ public final class InitBooklet{ //RF Generating Blocks new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFurnaceSolar), new PageTextOnly(1).addTextReplacement("", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText()); new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText()); - new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())).addItemToPage(new ItemStack(InitItems.itemCanolaSeed)).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText()); + new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())).addItemToPage(new ItemStack(InitItems.itemCanolaSeed)).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText()); new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant(); new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockBioReactor), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index bb7ddcab4..93420b256 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -140,6 +140,10 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ return new SPacketUpdateTileEntity(this.pos, -1, compound); } + public int getComparatorStrength(){ + return 0; + } + @Override public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){ this.readSyncableNBT(pkt.getNbtCompound(), NBTType.SYNC); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java index c2c9e3d7b..0e8c4b839 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java @@ -28,6 +28,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements private int lastEnergy; private int lastBurnTime; private int lastCurrentBurnTime; + private int lastCompare; public TileEntityCoalGenerator(){ super(1, "coalGenerator"); @@ -74,7 +75,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements this.storage.receiveEnergy(PRODUCE, false); } - if(this.currentBurnTime <= 0 && StackUtil.isValid(this.slots[0]) && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){ + if(!this.isRedstonePowered && this.currentBurnTime <= 0 && StackUtil.isValid(this.slots[0]) && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){ int burnTime = TileEntityFurnace.getItemBurnTime(this.slots[0]); this.maxBurnTime = burnTime; this.currentBurnTime = burnTime; @@ -82,7 +83,8 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements this.slots[0] = StackUtil.addStackSize(this.slots[0], -1, true); } - if(flag != this.currentBurnTime > 0){ + if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){ + this.lastCompare = this.getComparatorStrength(); this.markDirty(); } @@ -94,6 +96,12 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements } } + @Override + public int getComparatorStrength(){ + float calc = ((float)this.storage.getEnergyStored()/(float)this.storage.getMaxEnergyStored())*15F; + return (int)calc; + } + @Override public boolean isItemValidForSlot(int i, ItemStack stack){ return TileEntityFurnace.getItemBurnTime(stack) > 0; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index 9233e3ceb..054c8b735 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -45,6 +45,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari private int lastCanola; private int lastOil; private int lastProcessTime; + private int lastCompare; public TileEntityFermentingBarrel(){ super("fermentingBarrel"); @@ -83,13 +84,19 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari this.oilTank.fillInternal(new FluidStack(InitFluids.fluidOil, produce), true); this.canolaTank.drainInternal(produce, true); - this.markDirty(); } } else{ this.currentProcessTime = 0; } + int compare = this.getComparatorStrength(); + if(compare != this.lastCompare){ + this.lastCompare = compare; + + this.markDirty(); + } + if((this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()){ this.lastProcessTime = this.currentProcessTime; this.lastCanola = this.canolaTank.getFluidAmount(); @@ -98,6 +105,12 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } } + @Override + public int getComparatorStrength(){ + float calc = ((float)this.oilTank.getFluidAmount()/(float)this.oilTank.getCapacity())*15F; + return (int)calc; + } + @SideOnly(Side.CLIENT) public int getProcessScaled(int i){ return this.currentProcessTime*i/PROCESS_TIME; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 6d94c907a..d66ca0dbd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -45,6 +45,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing }; private int lastTankAmount; private int currentTime; + private int lastCompare; public TileEntityFluidCollector(String name){ super(name); @@ -65,6 +66,12 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing this.doWork(); } + @Override + public int getComparatorStrength(){ + float calc = ((float)this.tank.getFluidAmount()/(float)this.tank.getCapacity())*15F; + return (int)calc; + } + private void doWork(){ IBlockState state = this.worldObj.getBlockState(this.pos); Block block = state.getBlock(); @@ -160,6 +167,12 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing } } + if(this.lastCompare != this.getComparatorStrength()){ + this.lastCompare = this.getComparatorStrength(); + + this.markDirty(); + } + if(this.lastTankAmount != this.tank.getFluidAmount() && this.sendUpdateWithInterval()){ this.lastTankAmount = this.tank.getFluidAmount(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 6ede6d218..a5e7164dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -69,6 +70,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } } + @Override + public int getComparatorStrength(){ + return Container.calcRedstoneFromInventory(this); + } + @Override public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index 92f6ff85e..871c24fb7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -43,6 +43,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn private int lastTank; private int lastBurnTime; private int lastEnergyProduce; + private int lastCompare; public TileEntityOilGenerator(){ super("oilGenerator"); @@ -85,7 +86,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn this.currentBurnTime--; this.storage.receiveEnergy(this.currentEnergyProduce, false); } - else{ + else if(!this.isRedstonePowered){ this.currentEnergyProduce = this.getEnergyForCurrentFluid(); int fuelUsed = 50; @@ -98,7 +99,8 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } } - if(flag != this.currentBurnTime > 0){ + if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){ + this.lastCompare = this.getComparatorStrength(); this.markDirty(); } @@ -122,6 +124,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn return 0; } + @Override + public int getComparatorStrength(){ + float calc = ((float)this.storage.getEnergyStored()/(float)this.storage.getMaxEnergyStored())*15F; + return (int)calc; + } + @Override public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){ return this.storage.extractEnergy(maxExtract, simulate); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 57a24a509..8d1d436a2 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -783,8 +783,8 @@ booklet.actuallyadditions.chapter.treasureChest.text.2=Treasure Chests booklet.actuallyadditions.chapter.breaker.name=Breakers and Placers booklet.actuallyadditions.chapter.breaker.text.1=The Breaker breaks blocks in front of it. It can be oriented in every direction. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. booklet.actuallyadditions.chapter.breaker.text.2=The Placer places blocks in front of it. It can be oriented in every direction. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. -booklet.actuallyadditions.chapter.breaker.text.3=The Fluid Placer places liquids you supply it with. It needs 1000mB to place one block. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. -booklet.actuallyadditions.chapter.breaker.text.4=The Fluid Collector will collect 1000mB of liquids in front of it, that's a filled bucket. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. +booklet.actuallyadditions.chapter.breaker.text.3=The Fluid Placer places liquids you supply it with. It needs 1000mB to place one block. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. A Comparator will mesaure its Fluid Amount. +booklet.actuallyadditions.chapter.breaker.text.4=The Fluid Collector will collect 1000mB of liquids in front of it, that's a filled bucket. When right-clicking it with a Redstone Torch in hand, it will change between a mode where it gets deactivated by Redstone and a mode where it responds to pulses. A Comparator will mesaure its Fluid Amount. booklet.actuallyadditions.chapter.phantomfaces.name=Phantomfaces booklet.actuallyadditions.chapter.phantomfaces.text.1=Phantomfaces are a simple way to connect inventories together, they have a very important twist however: Instead of just connecting two inventories, a Phantomface simulates the inventory it is connected to, meaning you can put items into and pull out of the Phantomface itself. A Phantomface has a default range of blocks, but it can be upgraded with a Phantom Booster. Phantomfaces are connected by right-clicking an inventory with a Phantom Connector and then right-clicking the Phantomface. @@ -848,7 +848,7 @@ booklet.actuallyadditions.chapter.repairer.name=Item Repairer booklet.actuallyadditions.chapter.repairer.text.1=The Item Repairer uses RF/t to repair items that can be repaired in an Anvil without needing any materials! booklet.actuallyadditions.chapter.coalGen.name=Coal Generator -booklet.actuallyadditions.chapter.coalGen.text.1=The Coal Generator generates RF/t through the use of everything that can be put into a furnace. Note that it only starts burning something up if there's enough space for the energy generated. +booklet.actuallyadditions.chapter.coalGen.text.1=The Coal Generator generates CF/t through the use of everything that can be put into a furnace. Note that it only starts burning something up if the buffer isn't already full of power. It will stop generating when powered by Redstone. Additionally, using a Comparator will yield the percentage of energy stored. booklet.actuallyadditions.chapter.solarPanel.name=Solar Panel booklet.actuallyadditions.chapter.solarPanel.text.1=The Solar Panel produces RF/t when it has direct daylight above it and it is daytime. Any blocks above it that are transparent will decrease its efficiency, however. Panelled walls @@ -859,7 +859,8 @@ booklet.actuallyadditions.chapter.heatCollector.text.1=The Heat Collector< booklet.actuallyadditions.chapter.canola.name=Canola and Oil booklet.actuallyadditions.chapter.canola.text.1=Using Canola, you can make a simple, yet effective power generation system from natural resources. To do this, first find some Canola Plants in the wild and plant them on your farm. The Canola you get out of them can be used in a Canola Press to make Canola Oil. This can be used in an Oil Generator. It displays the amount of power it generates in its GUI, however, it can be upgraded further to yield more power than that! booklet.actuallyadditions.chapter.canola.text.2=For starters, you can use a Fermenting Barrel to convert the Canola Oil into Oil. If you're still not satisfied with the power that generates, place it on the ground and throw in a Crystallized Canola Seed to make Crystallized Oil. If that isn't enough for you either, make a Empowered Canola Seed, toss that into some Crystallized Oil to get Empowered Oil! -booklet.actuallyadditions.chapter.canola.text.5=If you break the Oil Generator, it will keep the liquid inside. If you want to empty it out, just place it in the crafting grid and all of the fluid will be drained. +booklet.actuallyadditions.chapter.canola.text.4=The Fermenting Barrel can have a Comparator attached to it which will result in the Redstone strength being equivalent to the percentage of the output tank. +booklet.actuallyadditions.chapter.canola.text.5=If you break the Oil Generator, it will keep the liquid inside. If you want to empty it out, just place it in the crafting grid and all of the fluid will be drained. It will stop generating when powered by Redstone. booklet.actuallyadditions.chapter.wings.name=Wings Of The Bats booklet.actuallyadditions.chapter.wings.text.1=Sometimes, bats will drop Wings. These wings can't really be used to fly, but that's just because they're not powerful enough. To make them more powerful, you can craft Wings Of The Bats. When you have these in your inventory, they will allow you to fly like in creative mode.