Added comparator outputs to a bunch of things

This commit is contained in:
Ellpeck 2016-12-22 21:29:19 +01:00
parent 798a56ec63
commit b8f8147418
9 changed files with 66 additions and 15 deletions

View file

@ -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;
}

View file

@ -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("<rf>", TileEntityCoalGenerator.PRODUCE));
chaptersIntroduction[4] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityCoalGenerator.PRODUCE), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText());
ArrayList<BookletPage> empowererPages = new ArrayList<BookletPage>();
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("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText());
new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", 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("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", 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();

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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();
}

View file

@ -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);

View file

@ -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);

View file

@ -783,8 +783,8 @@ booklet.actuallyadditions.chapter.treasureChest.text.2=<item>Treasure Chests<r>
booklet.actuallyadditions.chapter.breaker.name=Breakers and Placers
booklet.actuallyadditions.chapter.breaker.text.1=The <item>Breaker<r> breaks blocks in front of it. It can be oriented in every direction. <n>When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
booklet.actuallyadditions.chapter.breaker.text.2=The <item>Placer<r> places blocks in front of it. It can be oriented in every direction. <n>When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
booklet.actuallyadditions.chapter.breaker.text.3=The <item>Fluid Placer<r> places liquids you supply it with. It needs <imp>1000mB<r> to place one block. When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
booklet.actuallyadditions.chapter.breaker.text.4=The <item>Fluid Collector<r> will collect <imp>1000mB<r> of liquids in front of it, that's a filled bucket. When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>.
booklet.actuallyadditions.chapter.breaker.text.3=The <item>Fluid Placer<r> places liquids you supply it with. It needs <imp>1000mB<r> to place one block. When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>. A Comparator will mesaure its <imp>Fluid Amount<r>.
booklet.actuallyadditions.chapter.breaker.text.4=The <item>Fluid Collector<r> will collect <imp>1000mB<r> of liquids in front of it, that's a filled bucket. When right-clicking it with a <item>Redstone Torch<r> in hand, it will change between a mode where it <imp>gets deactivated by Redstone<r> and a mode where it <imp>responds to pulses<r>. A Comparator will mesaure its <imp>Fluid Amount<r>.
booklet.actuallyadditions.chapter.phantomfaces.name=Phantomfaces
booklet.actuallyadditions.chapter.phantomfaces.text.1=<item>Phantomfaces<r> are a simple way to <imp>connect inventories together<r>, they have a very important twist however: Instead of just connecting two inventories, a <item>Phantomface<r> <imp>simulates the inventory it is connected to<r>, meaning you can put items into and pull out of the Phantomface itself. A <item>Phantomface<r> has a <imp>default range of <range> blocks<r>, but it can be upgraded with a <item>Phantom Booster<r>. <item>Phantomfaces<r> are connected by <imp>right-clicking<r> an inventory with a <item>Phantom Connector<r> and then <imp>right-clicking<r> the <item>Phantomface.
@ -848,7 +848,7 @@ booklet.actuallyadditions.chapter.repairer.name=Item Repairer
booklet.actuallyadditions.chapter.repairer.text.1=The <item>Item Repairer<r> uses <imp><rf> RF/t<r> to repair items that can be repaired in an Anvil <imp>without needing any materials<r>!
booklet.actuallyadditions.chapter.coalGen.name=Coal Generator
booklet.actuallyadditions.chapter.coalGen.text.1=The <item>Coal Generator<r> generates <imp><rf> RF/t<r> through the use of everything that can be put into a furnace. <n>Note that it only starts burning something up if there's enough space for the energy generated.
booklet.actuallyadditions.chapter.coalGen.text.1=The <item>Coal Generator<r> generates <imp><rf> CF/t<r> through the use of everything that can be put into a furnace. <n>Note that it only starts burning something up if the buffer isn't already full of power. <n>It will <imp>stop generating<r> when powered by <imp>Redstone<r>. <n>Additionally, using a <item>Comparator<r> will yield the percentage of <imp>energy stored<r>.
booklet.actuallyadditions.chapter.solarPanel.name=Solar Panel
booklet.actuallyadditions.chapter.solarPanel.text.1=The <item>Solar Panel<r> <imp>produces <rf> RF/t<r> when it has direct daylight above it and it is daytime. Any blocks above it that are transparent will <imp>decrease its efficiency<r>, however. <n><n><i>Panelled walls
@ -859,7 +859,8 @@ booklet.actuallyadditions.chapter.heatCollector.text.1=The <item>Heat Collector<
booklet.actuallyadditions.chapter.canola.name=Canola and Oil
booklet.actuallyadditions.chapter.canola.text.1=Using <item>Canola<r>, you can make a simple, yet effective power generation system from <imp>natural resources<r>. <n>To do this, first find some <item>Canola Plants<r> in the wild and plant them on your farm. <n><n>The <item>Canola<r> you get out of them can be used in a <item>Canola Press<r> to make <item>Canola Oil<r>. <n><n>This can be <imp>used in an<r> <item>Oil Generator<r>. It displays the amount of power it generates in its GUI, however, it can be <imp>upgraded further<r> to yield <imp>more power<r> than that!
booklet.actuallyadditions.chapter.canola.text.2=For starters, you can use a <item>Fermenting Barrel<r> to convert the <item>Canola Oil<r> into <item>Oil<r>. <n><n>If you're still not satisfied with the power that generates, <imp>place it on the ground<r> and throw in a <item>Crystallized Canola Seed<r> to make <item>Crystallized Oil<r>. <n><n>If that isn't enough for you either, make a <item>Empowered Canola Seed<r>, toss that into some <item>Crystallized Oil<r> to get <item>Empowered Oil<r>!
booklet.actuallyadditions.chapter.canola.text.5=If you break the <item>Oil Generator<r>, it will keep the liquid inside. <n>If you want to empty it out, just <imp>place it in the crafting grid<r> and all of the fluid will be drained.
booklet.actuallyadditions.chapter.canola.text.4=The <item>Fermenting Barrel<r> can have a <item>Comparator<r> attached to it which will result in the Redstone strength being equivalent to the <imp>percentage<r> of the <imp>output tank<r>.
booklet.actuallyadditions.chapter.canola.text.5=If you break the <item>Oil Generator<r>, it will keep the liquid inside. <n>If you want to empty it out, just <imp>place it in the crafting grid<r> and all of the fluid will be drained. <n>It will <imp>stop generating<r> when powered by <imp>Redstone<r>.
booklet.actuallyadditions.chapter.wings.name=Wings Of The Bats
booklet.actuallyadditions.chapter.wings.text.1=Sometimes, bats will drop <item>Wings<r>. These wings can't really be used to fly, but that's just because they're not powerful enough. <n>To make them more powerful, you can craft <item>Wings Of The Bats<r>. When you have these in your inventory, they will allow you to <imp>fly like in creative mode<r>.