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 f16309246..25b2e7a70 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 @@ -238,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/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index ce4f536c6..85545ff1c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -228,6 +228,10 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ this.updateEntity(); } + public int getComparatorStrength(){ + return 0; + } + public void updateEntity(){ this.ticksElapsed++; 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 6d8286277..01bc45330 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.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -81,6 +82,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements return false; } + @Override + public int getComparatorStrength(){ + return Container.calcRedstoneFromInventory(this); + } + @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(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 7c29dd264..fbc3a3d63 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -106,10 +107,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn public void updateEntity(){ super.updateEntity(); if(!this.world.isRemote){ + int lastCompare = this.getComparatorStrength(); boolean flag = this.currentBurnTime > 0; if(this.currentBurnTime > 0 && this.currentEnergyProduce > 0){ this.currentBurnTime--; + this.storage.receiveEnergyInternal(this.currentEnergyProduce, false); } else if(!this.isRedstonePowered){ @@ -130,7 +133,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } } - if(flag != this.currentBurnTime > 0){ + if(flag != this.currentBurnTime > 0 || lastCompare != this.getComparatorStrength()){ this.markDirty(); } @@ -144,6 +147,12 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } } + @Override + public int getComparatorStrength(){ + float calc = ((float)this.storage.getEnergyStored()/(float)this.storage.getMaxEnergyStored())*15F; + return (int)calc; + } + @Override public IFluidHandler getFluidHandler(EnumFacing facing){ return facing != EnumFacing.DOWN ? this.tank : null; diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index bd9b372ab..62f42ffeb 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -881,7 +881,7 @@ 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. It will stop generating when powered by Redstone. +booklet.actuallyadditions.chapter.canola.text.5=If you break the Oil Generator, it will keep the liquid inside. Place it in the crafting grid to empty it out. It will stop generating when powered by Redstone. Additionally, using a Comparator will yield the percentage of energy stored. booklet.actuallyadditions.chapter.wings.name=Wings Of The Bats booklet.actuallyadditions.chapter.wings.text.1=Sometimes, bats will drop Wings. These wings can be used to make Wings Of The Bats, which allow you to fly in a creative way. However, after about seconds, your weight won't be supported anymore and you will drop to the ground. To remove exhaustion from your wings, either stand on the ground to remove exhaustion slowly, or hang on to the ceiling by flying up below a solid block like a bat while the wings aren't fully exhausted to remove exhaustion fast.