Lot of formatting.

This commit is contained in:
drcrazy 2018-06-22 18:22:16 +03:00
parent ec13f82628
commit 1de3fe5dc5
29 changed files with 540 additions and 544 deletions

View file

@ -71,7 +71,7 @@ public class TileAlarm extends TileEntity
@Override @Override
public void readFromNBT(NBTTagCompound compound) { public void readFromNBT(NBTTagCompound compound) {
if (compound != null && compound.hasKey("selectedSound")) { if (compound != null && compound.hasKey("selectedSound")) {
this.selectedSound = compound.getInteger("selectedSound"); selectedSound = compound.getInteger("selectedSound");
} }
super.readFromNBT(compound); super.readFromNBT(compound);
} }
@ -88,13 +88,13 @@ public class TileAlarm extends TileEntity
BlockAlarm.setActive(true, world, pos); BlockAlarm.setActive(true, world, pos);
switch (selectedSound) { switch (selectedSound) {
case 1: case 1:
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F); world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
break; break;
case 2: case 2:
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F); world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
break; break;
case 3: case 3:
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F); world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
break; break;
} }

View file

@ -33,7 +33,6 @@ import reborncore.api.IToolDrop;
import reborncore.api.power.IEnergyItemInfo; import reborncore.api.power.IEnergyItemInfo;
import reborncore.api.tile.IInventoryProvider; import reborncore.api.tile.IInventoryProvider;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
import reborncore.common.powerSystem.PoweredItem;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.registration.impl.ConfigRegistry;
@ -70,26 +69,18 @@ public class TileChargeOMat extends TilePowerAcceptor
return; return;
} }
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
if (this.inventory.getStackInSlot(i) != ItemStack.EMPTY) { if (!inventory.getStackInSlot(i).isEmpty()) {
if (this.getEnergy() > 0) { final ItemStack stack = inventory.getStackInSlot(i);
final ItemStack stack = this.inventory.getStackInSlot(i); if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) {
if (stack.getItem() instanceof IEnergyItemInfo) { IEnergyStorage powerItem = stack.getCapability(CapabilityEnergy.ENERGY, null);
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem(); int maxReceive = Math.min((powerItem.getMaxEnergyStored() - powerItem.getEnergyStored()),
if (PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)) { (int) ((IEnergyItemInfo) stack.getItem()).getMaxTransfer(stack));
if (canUseEnergy(item.getMaxTransfer(stack))) { double maxUse = Math.min((double) (maxReceive / RebornCoreConfig.euPerFU), getMaxInput());
useEnergy(item.getMaxTransfer(stack)); if (getEnergy() >= 0.0 && maxReceive > 0) {
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack); powerItem.receiveEnergy((int) useEnergy(maxUse) * RebornCoreConfig.euPerFU, false);
}
}
}
if(CompatManager.isIC2Loaded){
IC2ItemCharger.chargeIc2Item(this, stack);
}
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
int max = Math.min(maxInput, (int) getEnergy()) * RebornCoreConfig.euPerFU;
useEnergy(energyStorage.receiveEnergy(max, false) / RebornCoreConfig.euPerFU);
} }
} else if (CompatManager.isIC2Loaded) {
IC2ItemCharger.chargeIc2Item(this, stack);
} }
} }
} }
@ -135,7 +126,7 @@ public class TileChargeOMat extends TilePowerAcceptor
// IInventoryProvider // IInventoryProvider
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return inventory;
} }
// IContainerProvider // IContainerProvider

View file

@ -45,7 +45,7 @@ public class TileChunkLoader extends TilePowerAcceptor implements IToolDrop, IIn
@ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input (Value in EU)") @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input (Value in EU)")
public static int maxInput = 32; public static int maxInput = 32;
@ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxEnergy", comment = "Chunk Loader Max Energy (Value in EU)") @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxEnergy", comment = "Chunk Loader Max Energy (Value in EU)")
public static int maxEnergy = 10000; public static int maxEnergy = 10_000;
// @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderWrenchDropRate", comment = "Chunk Loader Wrench Drop Rate") // @ConfigRegistry(config = "machines", category = "chunk_loader", key = "ChunkLoaderWrenchDropRate", comment = "Chunk Loader Wrench Drop Rate")
public static float wrenchDropRate = 1.0F; public static float wrenchDropRate = 1.0F;

View file

@ -47,9 +47,4 @@ public class TileDigitalChest extends TileTechStorageBase implements IContainerP
return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory() return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory()
.tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this); .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this);
} }
@Override
public boolean canBeUpgraded() {
return false;
}
} }

View file

@ -77,8 +77,8 @@ public abstract class TileGenericMachine extends TilePowerAcceptor
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (!this.world.isRemote) { if (!world.isRemote) {
this.charge(energySlot); charge(energySlot);
} }
} }

View file

@ -45,7 +45,7 @@ import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class TileMatterFabricator extends TilePowerAcceptor public class TileMatterFabricator extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider, IContainerProvider { implements IToolDrop, IInventoryProvider, IContainerProvider {
@ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)") @ConfigRegistry(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)")
public static int maxInput = 8192; public static int maxInput = 8192;
@ -62,7 +62,7 @@ public class TileMatterFabricator extends TilePowerAcceptor
public TileMatterFabricator() { public TileMatterFabricator() {
super(); super();
} }
private boolean spaceForOutput() { private boolean spaceForOutput() {
for (int i = 6; i < 11; i++) { for (int i = 6; i < 11; i++) {
if (spaceForOutput(i)) { if (spaceForOutput(i)) {
@ -73,9 +73,9 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
private boolean spaceForOutput(int slot) { private boolean spaceForOutput(int slot) {
return this.inventory.getStackInSlot(slot).isEmpty() return inventory.getStackInSlot(slot).isEmpty()
|| ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), new ItemStack(ModItems.UU_MATTER), true, true) || ItemUtils.isItemEqual(inventory.getStackInSlot(slot), new ItemStack(ModItems.UU_MATTER), true, true)
&& this.inventory.getStackInSlot(slot).getCount() < 64; && inventory.getStackInSlot(slot).getCount() < 64;
} }
private void addOutputProducts() { private void addOutputProducts() {
@ -88,20 +88,21 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
private void addOutputProducts(int slot) { private void addOutputProducts(int slot) {
if (this.inventory.getStackInSlot(slot).isEmpty()) { if (inventory.getStackInSlot(slot).isEmpty()) {
this.inventory.setInventorySlotContents(slot, new ItemStack(ModItems.UU_MATTER)); inventory.setInventorySlotContents(slot, new ItemStack(ModItems.UU_MATTER));
} else if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), new ItemStack(ModItems.UU_MATTER), true, true)) { }
this.inventory.getStackInSlot(slot).setCount((Math.min(64, 1 + this.inventory.getStackInSlot(slot).getCount()))); else if (ItemUtils.isItemEqual(this.inventory.getStackInSlot(slot), new ItemStack(ModItems.UU_MATTER), true, true)) {
inventory.getStackInSlot(slot).setCount((Math.min(64, 1 + inventory.getStackInSlot(slot).getCount())));
} }
} }
public boolean decreaseStoredEnergy(final double aEnergy, final boolean aIgnoreTooLessEnergy) { public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) {
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) { if (getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
return false; return false;
} else { } else {
this.setEnergy(this.getEnergy() - aEnergy); setEnergy(getEnergy() - aEnergy);
if (this.getEnergy() < 0) { if (getEnergy() < 0) {
this.setEnergy(0); setEnergy(0);
return false; return false;
} else { } else {
return true; return true;
@ -109,8 +110,9 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
} }
public int getValue(final ItemStack itemStack) { public int getValue(ItemStack itemStack) {
if (itemStack.getItem() == ModItems.PARTS && itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) { if (itemStack.getItem() == ModItems.PARTS
&& itemStack.getItemDamage() == ItemParts.getPartByName("scrap").getItemDamage()) {
return 200; return 200;
} else if (itemStack.getItem() == ModItems.SCRAP_BOX) { } else if (itemStack.getItem() == ModItems.SCRAP_BOX) {
return 2000; return 2000;
@ -122,18 +124,18 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
return 0; return 0;
} }
public int getProgress() { public int getProgress() {
return this.amplifier; return amplifier;
} }
public void setProgress(final int progress) { public void setProgress(int progress) {
this.amplifier = progress; amplifier = progress;
} }
public int getProgressScaled(final int scale) { public int getProgressScaled(int scale) {
if (this.amplifier != 0) { if (amplifier != 0) {
return Math.min(this.amplifier * scale / fabricationRate, 100); return Math.min(amplifier * scale / fabricationRate, 100);
} }
return 0; return 0;
} }
@ -141,27 +143,29 @@ public class TileMatterFabricator extends TilePowerAcceptor
// TilePowerAcceptor // TilePowerAcceptor
@Override @Override
public void update() { public void update() {
if (world.isRemote){ return; } if (world.isRemote) {
return;
}
super.update(); super.update();
this.charge(11); this.charge(11);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
final ItemStack stack = this.inventory.getStackInSlot(i); final ItemStack stack = inventory.getStackInSlot(i);
if (!stack.isEmpty() && spaceForOutput()) { if (!stack.isEmpty() && spaceForOutput()) {
final int amp = this.getValue(stack); final int amp = getValue(stack);
final int euNeeded = amp * energyPerAmp; final int euNeeded = amp * energyPerAmp;
if (amp != 0 && this.canUseEnergy(euNeeded)) { if (amp != 0 && this.canUseEnergy(euNeeded)) {
this.useEnergy(euNeeded); useEnergy(euNeeded);
this.amplifier += amp; amplifier += amp;
this.inventory.decrStackSize(i, 1); inventory.decrStackSize(i, 1);
} }
} }
} }
if (amplifier >= fabricationRate) { if (amplifier >= fabricationRate) {
if (spaceForOutput()) { if (spaceForOutput()) {
this.addOutputProducts(); addOutputProducts();
amplifier -= fabricationRate; amplifier -= fabricationRate;
} }
} }
@ -173,12 +177,12 @@ public class TileMatterFabricator extends TilePowerAcceptor
} }
@Override @Override
public boolean canAcceptEnergy(final EnumFacing direction) { public boolean canAcceptEnergy(EnumFacing direction) {
return true; return true;
} }
@Override @Override
public boolean canProvideEnergy(final EnumFacing direction) { public boolean canProvideEnergy(EnumFacing direction) {
return false; return false;
} }
@ -191,28 +195,28 @@ public class TileMatterFabricator extends TilePowerAcceptor
public double getBaseMaxInput() { public double getBaseMaxInput() {
return maxInput; return maxInput;
} }
//TileLegacyMachineBase // TileLegacyMachineBase
@Override @Override
public boolean canBeUpgraded() { public boolean canBeUpgraded() {
return false; return false;
} }
// IToolDrop // IToolDrop
@Override @Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) { public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.MATTER_FABRICATOR, 1); return new ItemStack(ModBlocks.MATTER_FABRICATOR, 1);
} }
// IInventoryProvider // IInventoryProvider
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return inventory;
} }
// IContainerProvider // IContainerProvider
@Override @Override
public BuiltContainer createContainer(final EntityPlayer player) { public BuiltContainer createContainer(EntityPlayer player) {
return new ContainerBuilder("matterfabricator").player(player.inventory).inventory().hotbar().addInventory() return new ContainerBuilder("matterfabricator").player(player.inventory).inventory().hotbar().addInventory()
.tile(this).slot(0, 30, 20).slot(1, 50, 20).slot(2, 70, 20).slot(3, 90, 20).slot(4, 110, 20) .tile(this).slot(0, 30, 20).slot(1, 50, 20).slot(2, 70, 20).slot(3, 90, 20).slot(4, 110, 20)
.slot(5, 130, 20).outputSlot(6, 40, 66).outputSlot(7, 60, 66).outputSlot(8, 80, 66) .slot(5, 130, 20).outputSlot(6, 40, 66).outputSlot(7, 60, 66).outputSlot(8, 80, 66)

View file

@ -47,9 +47,4 @@ public class TileQuantumChest extends TileTechStorageBase implements IContainerP
return new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory() return new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory()
.tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this); .tile(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this);
} }
@Override
public boolean canBeUpgraded() {
return false;
}
} }

View file

@ -55,50 +55,62 @@ public class TileQuantumTank extends TileLegacyMachineBase
@ConfigRegistry(config = "machines", category = "quantum_tank", key = "QuantumTankMaxStorage", comment = "Maximum amount of millibuckets a Quantum Tank can store") @ConfigRegistry(config = "machines", category = "quantum_tank", key = "QuantumTankMaxStorage", comment = "Maximum amount of millibuckets a Quantum Tank can store")
public static int maxStorage = Integer.MAX_VALUE; public static int maxStorage = Integer.MAX_VALUE;
// @ConfigRegistry(config = "machines", category = "quantum_tank", key = "QuantumTankWrenchDropRate", comment = "Quantum Tank Wrench Drop Rate")
public static float wrenchDropRate = 1.0F;
public Tank tank = new Tank("TileQuantumTank", maxStorage, this); public Tank tank = new Tank("TileQuantumTank", maxStorage, this);
public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this); public Inventory inventory = new Inventory(3, "TileQuantumTank", 64, this);
public void readFromNBTWithoutCoords(final NBTTagCompound tagCompound) {
tank.readFromNBT(tagCompound);
}
public NBTTagCompound writeToNBTWithoutCoords(final NBTTagCompound tagCompound) {
tank.writeToNBT(tagCompound);
return tagCompound;
}
public ItemStack getDropWithNBT() {
final NBTTagCompound tileEntity = new NBTTagCompound();
final ItemStack dropStack = new ItemStack(ModBlocks.QUANTUM_TANK, 1);
this.writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
return dropStack;
}
// TileLegacyMachineBase
@Override
public void update() {
super.update();
if (!world.isRemote) {
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType()))
this.syncWithAll();
}
tank.compareAndUpdate();
}
@Override
public boolean canBeUpgraded() {
return false;
}
@Override @Override
public void readFromNBT(final NBTTagCompound tagCompound) { public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
this.readFromNBTWithoutCoords(tagCompound); readFromNBTWithoutCoords(tagCompound);
}
public void readFromNBTWithoutCoords(final NBTTagCompound tagCompound) {
this.tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
this.writeToNBTWithoutCoords(tagCompound); writeToNBTWithoutCoords(tagCompound);
return tagCompound;
}
public NBTTagCompound writeToNBTWithoutCoords(final NBTTagCompound tagCompound) {
this.tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) {
this.world.markBlockRangeForRenderUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ());
this.getPos().getX(), this.getPos().getY(), this.getPos().getZ()); readFromNBT(packet.getNbtCompound());
this.readFromNBT(packet.getNbtCompound());
}
@Override
public void update() {
super.update();
if (!this.world.isRemote) {
if (FluidUtils.drainContainers(this.tank, this.inventory, 0, 1)
|| FluidUtils.fillContainers(this.tank, this.inventory, 0, 1, this.tank.getFluidType()))
this.syncWithAll();
}
tank.compareAndUpdate();
} }
@Override @Override
@ -117,20 +129,19 @@ public class TileQuantumTank extends TileLegacyMachineBase
return super.getCapability(capability, facing); return super.getCapability(capability, facing);
} }
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IToolDrop
@Override @Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) { public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return this.getDropWithNBT(); return this.getDropWithNBT();
} }
public ItemStack getDropWithNBT() { // IListInfoProvider
final NBTTagCompound tileEntity = new NBTTagCompound();
final ItemStack dropStack = new ItemStack(ModBlocks.QUANTUM_TANK, 1);
this.writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
return dropStack;
}
@Override @Override
public void addInfo(final List<String> info, final boolean isRealTile) { public void addInfo(final List<String> info, final boolean isRealTile) {
if (isRealTile) { if (isRealTile) {
@ -141,23 +152,13 @@ public class TileQuantumTank extends TileLegacyMachineBase
} }
} }
info.add("Capacity " + this.tank.getCapacity() + " mb"); info.add("Capacity " + this.tank.getCapacity() + " mb");
}
@Override
public Inventory getInventory() {
return this.inventory;
} }
// IContainerProvider
@Override @Override
public BuiltContainer createContainer(final EntityPlayer player) { public BuiltContainer createContainer(final EntityPlayer player) {
return new ContainerBuilder("quantumtank").player(player.inventory).inventory().hotbar() return new ContainerBuilder("quantumtank").player(player.inventory).inventory().hotbar()
.addInventory().tile(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).addInventory() .addInventory().tile(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53).addInventory()
.create(this); .create(this);
} }
@Override
public boolean canBeUpgraded() {
return false;
}
} }

View file

@ -44,8 +44,10 @@ import reborncore.common.util.ItemUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
public class TileTechStorageBase extends TileLegacyMachineBase public class TileTechStorageBase extends TileLegacyMachineBase
implements IInventoryProvider, IToolDrop, IListInfoProvider, IDeepStorageUnit { implements IInventoryProvider, IToolDrop, IListInfoProvider, IDeepStorageUnit {
public final int maxCapacity; public final int maxCapacity;
public final Inventory inventory; public final Inventory inventory;
@ -57,148 +59,153 @@ public class TileTechStorageBase extends TileLegacyMachineBase
storedItem = ItemStack.EMPTY; storedItem = ItemStack.EMPTY;
inventory = new Inventory(3, name, maxCapacity, this); inventory = new Inventory(3, name, maxCapacity, this);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = ItemStack.EMPTY; storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) { if (tagCompound.hasKey("storedStack")) {
this.storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack")); storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
} }
if (!this.storedItem.isEmpty()) { if (!storedItem.isEmpty()) {
this.storedItem.setCount(Math.min(tagCompound.getInteger("storedQuantity"), this.maxCapacity)); storedItem.setCount(Math.min(tagCompound.getInteger("storedQuantity"), this.maxCapacity));
} }
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (!this.storedItem.isEmpty()) { if (!storedItem.isEmpty()) {
ItemStack temp = this.storedItem.copy(); ItemStack temp = storedItem.copy();
if (this.storedItem.getCount() > storedItem.getMaxStackSize()){ if (storedItem.getCount() > storedItem.getMaxStackSize()) {
temp.setCount(storedItem.getMaxStackSize()); temp.setCount(storedItem.getMaxStackSize());
} }
tagCompound.setTag("storedStack", temp.writeToNBT(new NBTTagCompound())); tagCompound.setTag("storedStack", temp.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", Math.min(this.storedItem.getCount(), this.maxCapacity)); tagCompound.setInteger("storedQuantity", Math.min(storedItem.getCount(), maxCapacity));
} else { } else {
tagCompound.setInteger("storedQuantity", 0); tagCompound.setInteger("storedQuantity", 0);
} }
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
public ItemStack getDropWithNBT() { public ItemStack getDropWithNBT() {
NBTTagCompound tileEntity = new NBTTagCompound(); NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(this.getBlockType(), 1); ItemStack dropStack = new ItemStack(getBlockType(), 1);
writeToNBTWithoutCoords(tileEntity); writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound()); dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity); dropStack.getTagCompound().setTag("tileEntity", tileEntity);
this.storedItem.setCount(0); storedItem.setCount(0);
setInventorySlotContents(1, ItemStack.EMPTY); setInventorySlotContents(1, ItemStack.EMPTY);
syncWithAll(); syncWithAll();
return dropStack; return dropStack;
} }
public InvWrapper getInvWrapper() { public InvWrapper getInvWrapper() {
if (this.invWrapper == null) if (invWrapper == null)
this.invWrapper = new InvWrapper(this); invWrapper = new InvWrapper(this);
return this.invWrapper; return invWrapper;
} }
public int getStoredCount() { public int getStoredCount() {
return this.storedItem.getCount(); return storedItem.getCount();
} }
public List<ItemStack> getContentDrops() { public List<ItemStack> getContentDrops() {
ArrayList<ItemStack> stacks = new ArrayList<>(); ArrayList<ItemStack> stacks = new ArrayList<>();
if (!this.getStoredItemType().isEmpty()) { if (!getStoredItemType().isEmpty()) {
if (!this.getStackInSlot(1).isEmpty()) { if (!getStackInSlot(1).isEmpty()) {
stacks.add(this.getStackInSlot(1)); stacks.add(getStackInSlot(1));
} }
for (int i = 0; i < this.getStoredCount() / 64; i++) { for (int i = 0; i < getStoredCount() / 64; i++) {
ItemStack droped = this.storedItem.copy(); ItemStack droped = storedItem.copy();
droped.setCount(64); droped.setCount(64);
stacks.add(droped); stacks.add(droped);
} }
if (this.getStoredCount() % 64 != 0) { if (getStoredCount() % 64 != 0) {
ItemStack droped = this.storedItem.copy(); ItemStack droped = storedItem.copy();
droped.setCount(this.getStoredCount() % 64); droped.setCount(getStoredCount() % 64);
stacks.add(droped); stacks.add(droped);
} }
} }
return stacks; return stacks;
} }
// TileLegacyMachineBase // TileLegacyMachineBase
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (!world.isRemote) { if (!world.isRemote) {
ItemStack outputStack = ItemStack.EMPTY; ItemStack outputStack = ItemStack.EMPTY;
if (!this.getStackInSlot(1).isEmpty()){ if (!getStackInSlot(1).isEmpty()) {
outputStack = this.getStackInSlot(1); outputStack = getStackInSlot(1);
} }
if (this.getStackInSlot(0) != ItemStack.EMPTY if (getStackInSlot(0) != ItemStack.EMPTY
&& (this.storedItem.getCount() + outputStack.getCount()) < this.maxCapacity) { && (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
ItemStack inputStack = this.getStackInSlot(0); ItemStack inputStack = getStackInSlot(0);
if (this.getStoredItemType().isEmpty() || (this.storedItem.isEmpty() if (getStoredItemType().isEmpty()
&& ItemUtils.isItemEqual(inputStack, outputStack, true, true))) { || (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) {
this.storedItem = inputStack; storedItem = inputStack;
this.setInventorySlotContents(0, ItemStack.EMPTY); setInventorySlotContents(0, ItemStack.EMPTY);
} else if (ItemUtils.isItemEqual(this.getStoredItemType(), inputStack, true, true)) { } else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) {
int reminder = this.maxCapacity - this.storedItem.getCount() - outputStack.getCount(); int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount();
if (inputStack.getCount() <= reminder) { if (inputStack.getCount() <= reminder) {
this.setStoredItemCount(inputStack.getCount()); setStoredItemCount(inputStack.getCount());
this.setInventorySlotContents(0, ItemStack.EMPTY); setInventorySlotContents(0, ItemStack.EMPTY);
} else { } else {
this.setStoredItemCount(this.maxCapacity - outputStack.getCount()); setStoredItemCount(maxCapacity - outputStack.getCount());
this.getStackInSlot(0).shrink(reminder); getStackInSlot(0).shrink(reminder);
} }
} }
this.markDirty(); markDirty();
this.syncWithAll(); syncWithAll();
} }
if (!this.storedItem.isEmpty()) { if (!storedItem.isEmpty()) {
if (outputStack == ItemStack.EMPTY) { if (outputStack == ItemStack.EMPTY) {
ItemStack delivered = this.storedItem.copy(); ItemStack delivered = storedItem.copy();
delivered.setCount(Math.min(this.storedItem.getCount(), delivered.getMaxStackSize())); delivered.setCount(Math.min(storedItem.getCount(), delivered.getMaxStackSize()));
this.storedItem.shrink(delivered.getCount()); storedItem.shrink(delivered.getCount());
if (this.storedItem.isEmpty()) if (storedItem.isEmpty()) {
this.storedItem = ItemStack.EMPTY; storedItem = ItemStack.EMPTY;
}
this.setInventorySlotContents(1, delivered); setInventorySlotContents(1, delivered);
this.markDirty(); markDirty();
this.syncWithAll(); syncWithAll();
} else if (ItemUtils.isItemEqual(this.storedItem, outputStack, true, true) } else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true)
&& outputStack.getCount() < outputStack.getMaxStackSize()) { && outputStack.getCount() < outputStack.getMaxStackSize()) {
int wanted = Math.min(this.storedItem.getCount(), int wanted = Math.min(storedItem.getCount(),
outputStack.getMaxStackSize() - outputStack.getCount()); outputStack.getMaxStackSize() - outputStack.getCount());
outputStack.setCount(outputStack.getCount() + wanted); outputStack.setCount(outputStack.getCount() + wanted);
this.storedItem.shrink(wanted); storedItem.shrink(wanted);
if (this.storedItem.isEmpty()) if (storedItem.isEmpty()) {
this.storedItem = ItemStack.EMPTY; storedItem = ItemStack.EMPTY;
this.markDirty(); }
this.syncWithAll(); markDirty();
syncWithAll();
} }
} }
} }
} }
@Override
public boolean canBeUpgraded() {
return false;
}
@Override @Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
world.markBlockRangeForRenderUpdate(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX(), world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ());
getPos().getY(), getPos().getZ());
readFromNBT(packet.getNbtCompound()); readFromNBT(packet.getNbtCompound());
} }
@ -214,9 +221,9 @@ public class TileTechStorageBase extends TileLegacyMachineBase
writeToNBTWithoutCoords(tagCompound); writeToNBTWithoutCoords(tagCompound);
return tagCompound; return tagCompound;
} }
@Override @Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) { public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getInvWrapper()); return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getInvWrapper());
} }
@ -224,18 +231,16 @@ public class TileTechStorageBase extends TileLegacyMachineBase
} }
@Override @Override
public boolean hasCapability(final net.minecraftforge.common.capabilities.Capability<?> capability, public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
@javax.annotation.Nullable
final net.minecraft.util.EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
} }
// IInventoryProvider // IInventoryProvider
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return inventory;
} }
// IToolDrop // IToolDrop
@Override @Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) { public ItemStack getToolDrop(EntityPlayer entityPlayer) {
@ -263,24 +268,24 @@ public class TileTechStorageBase extends TileLegacyMachineBase
// IDeepStorageUnit // IDeepStorageUnit
@Override @Override
public ItemStack getStoredItemType() { public ItemStack getStoredItemType() {
return this.storedItem.isEmpty() ? this.getStackInSlot(1) : this.storedItem; return storedItem.isEmpty() ? getStackInSlot(1) : storedItem;
} }
@Override @Override
public void setStoredItemCount(int amount) { public void setStoredItemCount(int amount) {
storedItem.grow(amount); storedItem.grow(amount);
this.markDirty(); markDirty();
} }
@Override @Override
public void setStoredItemType(ItemStack type, int amount) { public void setStoredItemType(ItemStack type, int amount) {
this.storedItem = type; storedItem = type;
storedItem.setCount(amount); storedItem.setCount(amount);
this.markDirty(); markDirty();
} }
@Override @Override
public int getMaxStoredCount() { public int getMaxStoredCount() {
return this.maxCapacity; return maxCapacity;
} }
} }

View file

@ -70,7 +70,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
@Override @Override
public void update() { public void update() {
super.update(); super.update();
this.ticksSinceLastChange++; ticksSinceLastChange++;
if(world.isRemote){ if(world.isRemote){
return; return;
@ -78,56 +78,56 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
// Check cells input slot 2 time per second // Check cells input slot 2 time per second
// Please, keep ticks counting on client also to report progress to GUI // Please, keep ticks counting on client also to report progress to GUI
if (this.ticksSinceLastChange >= 10) { if (ticksSinceLastChange >= 10) {
if (!this.inventory.getStackInSlot(0).isEmpty()) { if (!inventory.getStackInSlot(0).isEmpty()) {
FluidUtils.drainContainers(this.tank, this.inventory, 0, 1); FluidUtils.drainContainers(tank, inventory, 0, 1);
FluidUtils.fillContainers(this.tank, this.inventory, 0, 1, this.tank.getFluidType()); FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
} }
tank.setTileEntity(this); tank.setTileEntity(this);
tank.compareAndUpdate(); tank.compareAndUpdate();
this.ticksSinceLastChange = 0; ticksSinceLastChange = 0;
} }
if (this.tank.getFluidAmount() > 0) { if (tank.getFluidAmount() > 0) {
if (this.currentRecipe == null || !this.currentRecipe.getFluid().equals(this.tank.getFluidType())) if (currentRecipe == null || !currentRecipe.getFluid().equals(tank.getFluidType()))
this.currentRecipe = this.getRecipes().getRecipeForFluid(this.tank.getFluidType()).orElse(null); currentRecipe = getRecipes().getRecipeForFluid(tank.getFluidType()).orElse(null);
if (this.currentRecipe != null) { if (currentRecipe != null) {
final Integer euPerBucket = this.currentRecipe.getEnergyPerMb() * 1000; final Integer euPerBucket = currentRecipe.getEnergyPerMb() * 1000;
final float millibucketsPerTick = this.euTick * 1000 / (float) euPerBucket; final float millibucketsPerTick = euTick * 1000 / (float) euPerBucket;
if (this.tryAddingEnergy(this.euTick)) { if (tryAddingEnergy(euTick)) {
this.pendingWithdraw += millibucketsPerTick; pendingWithdraw += millibucketsPerTick;
final int currentWithdraw = (int) this.pendingWithdraw; final int currentWithdraw = (int) pendingWithdraw;
this.pendingWithdraw -= currentWithdraw; pendingWithdraw -= currentWithdraw;
this.tank.drain(currentWithdraw, true); tank.drain(currentWithdraw, true);
this.lastOutput = this.world.getTotalWorldTime(); lastOutput = world.getTotalWorldTime();
} }
} }
} }
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive()) if (world.getTotalWorldTime() - lastOutput < 30 && !isActive()) {
this.world.setBlockState(this.getPos(), this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, true)); world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, true));
else if (this.world.getTotalWorldTime() - this.lastOutput > 30 && this.isActive()) }
this.world.setBlockState(this.getPos(), this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, false)); else if (world.getTotalWorldTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, false));
}
} }
public int getProgressScaled(final int scale) { public int getProgressScaled(int scale) {
if (this.isActive()){ if (isActive()){
return this.ticksSinceLastChange * scale; return ticksSinceLastChange * scale;
} }
return 0; return 0;
} }
protected boolean tryAddingEnergy(int amount) { protected boolean tryAddingEnergy(int amount) {
if (this.getMaxPower() - this.getEnergy() >= amount) { if (getMaxPower() - getEnergy() >= amount) {
addEnergy(amount); addEnergy(amount);
return true; return true;
} else if (this.getMaxPower() - this.getEnergy() > 0) { } else if (getMaxPower() - getEnergy() > 0) {
addEnergy(this.getMaxPower() - this.getEnergy()); addEnergy(getMaxPower() - getEnergy());
return true; return true;
} }
@ -135,8 +135,8 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
} }
protected boolean acceptFluid() { protected boolean acceptFluid() {
if (!this.getStackInSlot(0).isEmpty()) { if (!getStackInSlot(0).isEmpty()) {
FluidStack stack = FluidUtils.getFluidStackInContainer(this.getStackInSlot(0)); FluidStack stack = FluidUtils.getFluidStackInContainer(getStackInSlot(0));
if (stack != null) if (stack != null)
return recipes.getRecipeForFluid(stack.getFluid()).isPresent(); return recipes.getRecipeForFluid(stack.getFluid()).isPresent();
} }

View file

@ -48,7 +48,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override @Override
public void update() { public void update() {
super.update(); super.update();
this.setEnergy(getMaxPower()); setEnergy(getMaxPower());
} }
@Override @Override
@ -58,7 +58,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override @Override
public double getBaseMaxPower() { public double getBaseMaxPower() {
return 1000000; return 1_000_000;
} }
@Override @Override
@ -73,7 +73,7 @@ public class TileCreativeSolarPanel extends TilePowerAcceptor implements IToolDr
@Override @Override
public double getBaseMaxOutput() { public double getBaseMaxOutput() {
return 16192; return 16_192;
} }
@Override @Override

View file

@ -40,7 +40,8 @@ import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop, IInventoryProvider { public class TileDragonEggSyphon extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider {
@ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)") @ConfigRegistry(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)")
public static int maxOutput = 128; public static int maxOutput = 128;
@ -55,27 +56,7 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
public TileDragonEggSyphon() { public TileDragonEggSyphon() {
super(); super();
} }
@Override
public void update() {
super.update();
if (!world.isRemote) {
if (world.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(energyPerTick))
this.lastOutput = this.world.getTotalWorldTime();
}
if (this.world.getTotalWorldTime() - this.lastOutput < 30 && !this.isActive())
this.world.setBlockState(this.getPos(),
this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, true));
else if (this.world.getTotalWorldTime() - this.lastOutput > 30 && this.isActive())
this.world.setBlockState(this.getPos(),
this.world.getBlockState(this.getPos()).withProperty(BlockMachineBase.ACTIVE, false));
}
}
private boolean tryAddingEnergy(int amount) { private boolean tryAddingEnergy(int amount) {
if (this.getMaxPower() - this.getEnergy() >= amount) { if (this.getMaxPower() - this.getEnergy() >= amount) {
addEnergy(amount); addEnergy(amount);
@ -86,14 +67,25 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
} }
return false; return false;
} }
// TilePowerAcceptor
@Override @Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) { public void update() {
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1); super.update();
}
public boolean isComplete() { if (!world.isRemote) {
return false; if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(energyPerTick))
lastOutput = world.getTotalWorldTime();
}
if (world.getTotalWorldTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, true));
} else if (world.getTotalWorldTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockMachineBase.ACTIVE, false));
}
}
} }
@Override @Override
@ -120,7 +112,14 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
public double getBaseMaxInput() { public double getBaseMaxInput() {
return 0; return 0;
} }
// IToolDrop
@Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.DRAGON_EGG_SYPHON, 1);
}
// IInventoryProvider
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return inventory; return inventory;

View file

@ -45,7 +45,7 @@ public class TileInterdimensionalSU extends TileEnergyStorage implements IContai
@ConfigRegistry(config = "machines", category = "idsu", key = "IdsuMaxOutput", comment = "IDSU Max Output (Value in EU)") @ConfigRegistry(config = "machines", category = "idsu", key = "IdsuMaxOutput", comment = "IDSU Max Output (Value in EU)")
public static int maxOutput = 8192; public static int maxOutput = 8192;
@ConfigRegistry(config = "machines", category = "idsu", key = "IdsuMaxEnergy", comment = "IDSU Max Energy (Value in EU)") @ConfigRegistry(config = "machines", category = "idsu", key = "IdsuMaxEnergy", comment = "IDSU Max Energy (Value in EU)")
public static int maxEnergy = 100000000; public static int maxEnergy = 100_000_000;
public String ownerUdid; public String ownerUdid;

View file

@ -72,9 +72,9 @@ public class TileLSUStorage extends TileLegacyMachineBase
} }
public final void rebuildNetwork() { public final void rebuildNetwork() {
this.removeFromNetwork(); removeFromNetwork();
this.resetNetwork(); resetNetwork();
this.findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ()); findAndJoinNetwork(world, pos.getX(), pos.getY(), pos.getZ());
} }
// TileLegacyMachineBase // TileLegacyMachineBase
@ -82,7 +82,7 @@ public class TileLSUStorage extends TileLegacyMachineBase
public void update() { public void update() {
super.update(); super.update();
if (network == null) { if (network == null) {
findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ()); findAndJoinNetwork(world, pos.getX(), pos.getY(), pos.getZ());
} else { } else {
if (network.master != null if (network.master != null
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(), && network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
@ -94,7 +94,7 @@ public class TileLSUStorage extends TileLegacyMachineBase
// IToolDrop // IToolDrop
@Override @Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) { public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.LSU_STORAGE, 1); return new ItemStack(ModBlocks.LSU_STORAGE, 1);
} }
} }

View file

@ -26,6 +26,7 @@ package techreborn.tiles.lesu;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import reborncore.api.power.EnumPowerTier; import reborncore.api.power.EnumPowerTier;
@ -50,7 +51,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
@ConfigRegistry(config = "machines", category = "lesu", key = "LesuMaxOutput", comment = "LESU Base Output (Value in EU)") @ConfigRegistry(config = "machines", category = "lesu", key = "LesuMaxOutput", comment = "LESU Base Output (Value in EU)")
public static int baseOutput = 16; public static int baseOutput = 16;
@ConfigRegistry(config = "machines", category = "lesu", key = "LesuMaxEnergyPerBlock", comment = "LESU Max Energy Per Block (Value in EU)") @ConfigRegistry(config = "machines", category = "lesu", key = "LesuMaxEnergyPerBlock", comment = "LESU Max Energy Per Block (Value in EU)")
public static int storagePerBlock = 1000000; public static int storagePerBlock = 1_000_000;
@ConfigRegistry(config = "machines", category = "lesu", key = "LesuExtraIO", comment = "LESU Extra I/O Multiplier") @ConfigRegistry(config = "machines", category = "lesu", key = "LesuExtraIO", comment = "LESU Extra I/O Multiplier")
public static int extraIOPerBlock = 8; public static int extraIOPerBlock = 8;
@ -58,7 +59,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
private ArrayList<LesuNetwork> countedNetworks = new ArrayList<>(); private ArrayList<LesuNetwork> countedNetworks = new ArrayList<>();
public TileLapotronicSU() { public TileLapotronicSU() {
super("LESU", 2, ModBlocks.LAPOTRONIC_SU, EnumPowerTier.INSANE, 8192, baseOutput, 1000000); super("LESU", 2, ModBlocks.LAPOTRONIC_SU, EnumPowerTier.INSANE, 8192, baseOutput, 1_000_000);
checkOverfill = false; checkOverfill = false;
} }
@ -71,28 +72,28 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
countedNetworks.clear(); countedNetworks.clear();
connectedBlocks = 0; connectedBlocks = 0;
for (EnumFacing dir : EnumFacing.values()) { for (EnumFacing dir : EnumFacing.values()) {
if (world.getTileEntity( BlockPos adjucentBlockPos = new BlockPos(pos.getX() + dir.getFrontOffsetX(),
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(), pos.getY() + dir.getFrontOffsetY(), pos.getZ() + dir.getFrontOffsetZ());
getPos().getZ() + dir.getFrontOffsetZ())) instanceof TileLSUStorage) { TileEntity adjucentTile = world.getTileEntity(adjucentBlockPos);
if (((TileLSUStorage) world.getTileEntity( if (adjucentTile == null || !(adjucentTile instanceof TileLSUStorage)) {
new BlockPos(getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(), continue;
getPos().getZ() + dir.getFrontOffsetZ()))).network != null) { }
LesuNetwork network = ((TileLSUStorage) world.getTileEntity(new BlockPos( if (((TileLSUStorage) adjucentTile).network == null) {
getPos().getX() + dir.getFrontOffsetX(), getPos().getY() + dir.getFrontOffsetY(), continue;
getPos().getZ() + dir.getFrontOffsetZ()))).network; }
if (!countedNetworks.contains(network)) { LesuNetwork network = ((TileLSUStorage) adjucentTile).network;
if (network.master == null || network.master == this) { if (!countedNetworks.contains(network)) {
connectedBlocks += network.storages.size(); if (network.master == null || network.master == this) {
countedNetworks.add(network); connectedBlocks += network.storages.size();
network.master = this; countedNetworks.add(network);
break; network.master = this;
} break;
}
} }
} }
} }
setMaxStorage(); setMaxStorage();
this.maxOutput = (connectedBlocks * extraIOPerBlock) + baseOutput; maxOutput = (connectedBlocks * extraIOPerBlock) + baseOutput;
} }
@Override @Override
@ -105,7 +106,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
} }
public int getOutputRate() { public int getOutputRate() {
return this.maxOutput; return maxOutput;
} }
public void setOutputRate(int output) { public void setOutputRate(int output) {
@ -113,7 +114,7 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
} }
public int getConnectedBlocksNum() { public int getConnectedBlocksNum() {
return this.connectedBlocks; return connectedBlocks;
} }
public void setConnectedBlocksNum(int value) { public void setConnectedBlocksNum(int value) {
@ -124,9 +125,9 @@ public class TileLapotronicSU extends TileEnergyStorage implements IContainerPro
} }
public void setMaxStorage(){ public void setMaxStorage(){
this.maxStorage = (this.connectedBlocks + 1) * storagePerBlock; maxStorage = (connectedBlocks + 1) * storagePerBlock;
if (this.maxStorage < 0 || this.maxStorage > Integer.MAX_VALUE / RebornCoreConfig.euPerFU) { if (maxStorage < 0 || maxStorage > Integer.MAX_VALUE / RebornCoreConfig.euPerFU) {
this.maxStorage = Integer.MAX_VALUE / RebornCoreConfig.euPerFU; maxStorage = Integer.MAX_VALUE / RebornCoreConfig.euPerFU;
} }
} }

View file

@ -42,20 +42,21 @@ public class TileLamp extends TilePowerAcceptor
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (world != null && !world.isRemote) { if (world == null || world.isRemote) {
IBlockState state = world.getBlockState(pos); return;
Block b = state.getBlock();
if (b instanceof BlockLamp) {
double cost = getEuPerTick(((BlockLamp)b).getCost());
if (this.getEnergy() > cost) {
useEnergy(getEuPerTick(cost));
if (!BlockLamp.isActive(state))
BlockLamp.setActive(true, world, pos);
} else if (BlockLamp.isActive(state)) {
BlockLamp.setActive(false, world, pos);
}
}
} }
IBlockState state = world.getBlockState(pos);
Block b = state.getBlock();
if (b instanceof BlockLamp) {
double cost = getEuPerTick(((BlockLamp) b).getCost());
if (getEnergy() > cost) {
useEnergy(getEuPerTick(cost));
if (!BlockLamp.isActive(state))
BlockLamp.setActive(true, world, pos);
} else if (BlockLamp.isActive(state)) {
BlockLamp.setActive(false, world, pos);
}
}
} }
@Override @Override

View file

@ -59,15 +59,15 @@ public class TileDistillationTower extends TileGenericMachine implements IContai
} }
public boolean getMutliBlock() { public boolean getMutliBlock() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
return false; return false;
} }
final boolean layer0 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET); final boolean layer0 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
final boolean layer1 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 1, 0)); final boolean layer1 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 1, 0));
final boolean layer2 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0)); final boolean layer2 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
final boolean layer3 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 3, 0)); final boolean layer3 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.ADVANCED_CASING, new BlockPos(0, 3, 0));
final Block centerBlock1 = this.multiblockChecker.getBlock(0, 1, 0).getBlock(); final Block centerBlock1 = multiblockChecker.getBlock(0, 1, 0).getBlock();
final Block centerBlock2 = this.multiblockChecker.getBlock(0, 2, 0).getBlock(); final Block centerBlock2 = multiblockChecker.getBlock(0, 2, 0).getBlock();
final boolean center1 = (centerBlock1 == Blocks.AIR); final boolean center1 = (centerBlock1 == Blocks.AIR);
final boolean center2 = (centerBlock2 == Blocks.AIR); final boolean center2 = (centerBlock2 == Blocks.AIR);
return layer0 && layer1 && layer2 && layer3 && center1 && center2; return layer0 && layer1 && layer2 && layer3 && center1 && center2;
@ -76,9 +76,9 @@ public class TileDistillationTower extends TileGenericMachine implements IContai
// TileGenericMachine // TileGenericMachine
@Override @Override
public void update() { public void update() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
this.multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
if (!world.isRemote && getMutliBlock()){ if (!world.isRemote && getMutliBlock()){

View file

@ -85,8 +85,8 @@ public class TileFluidReplicator extends TileGenericMachine implements IContaine
@Override @Override
public void update() { public void update() {
if (multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = getPos().offset(getFacing().getOpposite(), 2); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
ticksSinceLastChange++; ticksSinceLastChange++;

View file

@ -57,18 +57,18 @@ public class TileImplosionCompressor extends TileGenericMachine implements ICont
} }
public boolean getMutliBlock() { public boolean getMutliBlock() {
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET); final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET);
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 2, 0)); final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 2, 0));
final boolean chamber = this.multiblockChecker.checkRingYHollow(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0)); final boolean chamber = multiblockChecker.checkRingYHollow(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0));
return down && chamber && up; return down && chamber && up;
} }
// TileGenericMachine // TileGenericMachine
@Override @Override
public void update() { public void update() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
this.multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
if (!world.isRemote && getMutliBlock()){ if (!world.isRemote && getMutliBlock()){
@ -80,7 +80,7 @@ public class TileImplosionCompressor extends TileGenericMachine implements ICont
@Override @Override
public void validate() { public void validate() {
super.validate(); super.validate();
this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down(3)); multiblockChecker = new MultiblockChecker(world, pos.down(3));
} }
// IContainerProvider // IContainerProvider

View file

@ -70,13 +70,13 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
} }
public int getHeat() { public int getHeat() {
if (!this.getMutliBlock()){ if (!getMutliBlock()){
return 0; return 0;
} }
// Bottom center of multiblock // Bottom center of multiblock
final BlockPos location = this.getPos().offset(this.getFacing().getOpposite(), 2); final BlockPos location = pos.offset(getFacing().getOpposite(), 2);
final TileEntity tileEntity = this.world.getTileEntity(location); final TileEntity tileEntity = world.getTileEntity(location);
if (tileEntity instanceof TileMachineCasing) { if (tileEntity instanceof TileMachineCasing) {
if (((TileMachineCasing) tileEntity).isConnected() if (((TileMachineCasing) tileEntity).isConnected()
@ -86,21 +86,18 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
int heat = 0; int heat = 0;
// Bottom center shouldn't have any tile entities below it // Bottom center shouldn't have any tile entities below it
if (this.world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ())) if (world.getBlockState(new BlockPos(location.getX(), location.getY() - 1, location.getZ()))
.getBlock() == tileEntity.getBlockType()) { .getBlock() == tileEntity.getBlockType()) {
return 0; return 0;
} }
for (final IMultiblockPart part : casing.connectedParts) { for (final IMultiblockPart part : casing.connectedParts) {
final BlockMachineCasing casing1 = (BlockMachineCasing) this.world.getBlockState(part.getPos()) final BlockMachineCasing casing1 = (BlockMachineCasing) world.getBlockState(part.getPos()).getBlock();
.getBlock(); heat += casing1.getHeatFromState(world.getBlockState(part.getPos()));
heat += casing1.getHeatFromState(this.world.getBlockState(part.getPos()));
} }
if (this.world.getBlockState(location.offset(EnumFacing.UP, 1)).getBlock().getUnlocalizedName() if (world.getBlockState(location.offset(EnumFacing.UP, 1)).getBlock().getUnlocalizedName().equals("tile.lava")
.equals("tile.lava") && world.getBlockState(location.offset(EnumFacing.UP, 2)).getBlock().getUnlocalizedName().equals("tile.lava")) {
&& this.world.getBlockState(location.offset(EnumFacing.UP, 2)).getBlock().getUnlocalizedName()
.equals("tile.lava")) {
heat += 500; heat += 500;
} }
return heat; return heat;
@ -111,31 +108,31 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
} }
public boolean getMutliBlock() { public boolean getMutliBlock() {
final boolean layer0 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, MultiblockChecker.ZERO_OFFSET); final boolean layer0 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, MultiblockChecker.ZERO_OFFSET);
final boolean layer1 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 1, 0)); final boolean layer1 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 1, 0));
final boolean layer2 = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 2, 0)); final boolean layer2 = multiblockChecker.checkRingY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 2, 0));
final boolean layer3 = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 3, 0)); final boolean layer3 = multiblockChecker.checkRectY(1, 1, MultiblockChecker.CASING_ANY, new BlockPos(0, 3, 0));
final Block centerBlock1 = this.multiblockChecker.getBlock(0, 1, 0).getBlock(); final Block centerBlock1 = multiblockChecker.getBlock(0, 1, 0).getBlock();
final Block centerBlock2 = this.multiblockChecker.getBlock(0, 2, 0).getBlock(); final Block centerBlock2 = multiblockChecker.getBlock(0, 2, 0).getBlock();
final boolean center1 = (centerBlock1 == Blocks.AIR || centerBlock1 == Blocks.LAVA); final boolean center1 = (centerBlock1 == Blocks.AIR || centerBlock1 == Blocks.LAVA);
final boolean center2 = (centerBlock2 == Blocks.AIR || centerBlock2 == Blocks.LAVA); final boolean center2 = (centerBlock2 == Blocks.AIR || centerBlock2 == Blocks.LAVA);
return layer0 && layer1 && layer2 && layer3 && center1 && center2; return layer0 && layer1 && layer2 && layer3 && center1 && center2;
} }
public void setHeat(final int heat) { public void setHeat(final int heat) {
this.cachedHeat = heat; cachedHeat = heat;
} }
public int getCachedHeat() { public int getCachedHeat() {
return this.cachedHeat; return cachedHeat;
} }
// TileGenericMachine // TileGenericMachine
@Override @Override
public void update() { public void update() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2);
this.multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
if (!world.isRemote && getMutliBlock()){ if (!world.isRemote && getMutliBlock()){
@ -146,9 +143,8 @@ public class TileIndustrialBlastFurnace extends TileGenericMachine implements IC
// TileLegacyMachineBase // TileLegacyMachineBase
@Override @Override
public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) { public void onDataPacket(final NetworkManager net, final SPacketUpdateTileEntity packet) {
this.world.markBlockRangeForRenderUpdate(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), this.getPos().getX(), world.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ());
this.getPos().getY(), this.getPos().getZ()); readFromNBT(packet.getNbtCompound());
this.readFromNBT(packet.getNbtCompound());
} }
// IContainerProvider // IContainerProvider

View file

@ -80,34 +80,32 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
if (multiblockChecker == null) { if (multiblockChecker == null) {
return false; return false;
} }
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
MultiblockChecker.ZERO_OFFSET); final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0));
new BlockPos(0, 2, 0)); final IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING,
new BlockPos(0, 1, 0));
final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0);
final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid
|| centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER); || centerBlock.getBlock() instanceof IFluidBlock)
&& centerBlock.getMaterial() == Material.WATER);
return down && center && blade && up; return down && center && blade && up;
} }
// TilePowerAcceptor // TilePowerAcceptor
@Override @Override
public void update() { public void update() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2).down(); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).down();
this.multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
this.ticksSinceLastChange++; ticksSinceLastChange++;
// Check cells input slot 2 time per second // Check cells input slot 2 time per second
if (!world.isRemote && this.ticksSinceLastChange >= 10) { if (!world.isRemote && ticksSinceLastChange >= 10) {
if (!this.inventory.getStackInSlot(1).isEmpty()) { if (!inventory.getStackInSlot(1).isEmpty()) {
FluidUtils.drainContainers(this.tank, this.inventory, 1, 6); FluidUtils.drainContainers(tank, inventory, 1, 6);
FluidUtils.fillContainers(this.tank, this.inventory, 1, 6, this.tank.getFluidType()); FluidUtils.fillContainers(tank, inventory, 1, 6, tank.getFluidType());
} }
this.ticksSinceLastChange = 0; ticksSinceLastChange = 0;
} }
if (!world.isRemote && getMutliBlock()) { if (!world.isRemote && getMutliBlock()) {
@ -120,13 +118,13 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
@Override @Override
public void readFromNBT(final NBTTagCompound tagCompound) { public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
this.tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
this.tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@ -177,7 +175,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
return false; return false;
} }
final FluidStack recipeFluid = recipe.fluidStack; final FluidStack recipeFluid = recipe.fluidStack;
final FluidStack tankFluid = this.tank.getFluid(); final FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) { if (recipe.fluidStack == null) {
return true; return true;
} }
@ -195,7 +193,7 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
@Override @Override
public boolean onCraft(final TileEntity tile, final IndustrialGrinderRecipe recipe) { public boolean onCraft(final TileEntity tile, final IndustrialGrinderRecipe recipe) {
final FluidStack recipeFluid = recipe.fluidStack; final FluidStack recipeFluid = recipe.fluidStack;
final FluidStack tankFluid = this.tank.getFluid(); final FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) { if (recipe.fluidStack == null) {
return true; return true;
} }
@ -205,12 +203,12 @@ public class TileIndustrialGrinder extends TileGenericMachine implements IContai
if (tankFluid.isFluidEqual(recipeFluid)) { if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) { if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.amount == recipeFluid.amount) { if (tankFluid.amount == recipeFluid.amount) {
this.tank.setFluid(null); tank.setFluid(null);
} }
else { else {
tankFluid.amount -= recipeFluid.amount; tankFluid.amount -= recipeFluid.amount;
} }
this.syncWithAll(); syncWithAll();
return true; return true;
} }
} }

View file

@ -80,34 +80,32 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
if (multiblockChecker == null) { if (multiblockChecker == null) {
return false; return false;
} }
final boolean down = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, final boolean down = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, MultiblockChecker.ZERO_OFFSET);
MultiblockChecker.ZERO_OFFSET); final boolean up = multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, new BlockPos(0, 2, 0));
final boolean up = this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.STANDARD_CASING, final boolean blade = multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING, new BlockPos(0, 1, 0));
new BlockPos(0, 2, 0)); final IBlockState centerBlock = multiblockChecker.getBlock(0, 1, 0);
final boolean blade = this.multiblockChecker.checkRingY(1, 1, MultiblockChecker.REINFORCED_CASING,
new BlockPos(0, 1, 0));
final IBlockState centerBlock = this.multiblockChecker.getBlock(0, 1, 0);
final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid final boolean center = ((centerBlock.getBlock() instanceof BlockLiquid
|| centerBlock.getBlock() instanceof IFluidBlock) && centerBlock.getMaterial() == Material.WATER); || centerBlock.getBlock() instanceof IFluidBlock)
&& centerBlock.getMaterial() == Material.WATER);
return down && center && blade && up; return down && center && blade && up;
} }
// TileGenericMachine // TileGenericMachine
@Override @Override
public void update() { public void update() {
if (this.multiblockChecker == null) { if (multiblockChecker == null) {
final BlockPos pos = this.getPos().offset(this.getFacing().getOpposite(), 2).down(); final BlockPos downCenter = pos.offset(getFacing().getOpposite(), 2).down();
this.multiblockChecker = new MultiblockChecker(this.world, pos); multiblockChecker = new MultiblockChecker(world, downCenter);
} }
this.ticksSinceLastChange++; ticksSinceLastChange++;
// Check cells input slot 2 time per second // Check cells input slot 2 time per second
if (!world.isRemote && this.ticksSinceLastChange >= 10) { if (!world.isRemote && ticksSinceLastChange >= 10) {
if (!this.inventory.getStackInSlot(1).isEmpty()) { if (!inventory.getStackInSlot(1).isEmpty()) {
FluidUtils.drainContainers(this.tank, this.inventory, 1, 5); FluidUtils.drainContainers(tank, inventory, 1, 5);
FluidUtils.fillContainers(this.tank, this.inventory, 1, 5, this.tank.getFluidType()); FluidUtils.fillContainers(tank, inventory, 1, 5, tank.getFluidType());
} }
this.ticksSinceLastChange = 0; ticksSinceLastChange = 0;
} }
if (!world.isRemote && getMutliBlock()) { if (!world.isRemote && getMutliBlock()) {
@ -120,13 +118,13 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
@Override @Override
public void readFromNBT(final NBTTagCompound tagCompound) { public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
this.tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
} }
@Override @Override
public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(final NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
this.tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
return tagCompound; return tagCompound;
} }
@ -141,7 +139,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
@Override @Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) { public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
if (this.tank != null) { if (tank != null) {
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank); return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
} }
} }
@ -177,7 +175,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
return false; return false;
} }
final FluidStack recipeFluid = recipe.fluidStack; final FluidStack recipeFluid = recipe.fluidStack;
final FluidStack tankFluid = this.tank.getFluid(); final FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) { if (recipe.fluidStack == null) {
return true; return true;
} }
@ -195,7 +193,7 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
@Override @Override
public boolean onCraft(TileEntity tile, IndustrialSawmillRecipe recipe) { public boolean onCraft(TileEntity tile, IndustrialSawmillRecipe recipe) {
final FluidStack recipeFluid = recipe.fluidStack; final FluidStack recipeFluid = recipe.fluidStack;
final FluidStack tankFluid = this.tank.getFluid(); final FluidStack tankFluid = tank.getFluid();
if (recipe.fluidStack == null) { if (recipe.fluidStack == null) {
return true; return true;
} }
@ -205,11 +203,11 @@ public class TileIndustrialSawmill extends TileGenericMachine implements IContai
if (tankFluid.isFluidEqual(recipeFluid)) { if (tankFluid.isFluidEqual(recipeFluid)) {
if (tankFluid.amount >= recipeFluid.amount) { if (tankFluid.amount >= recipeFluid.amount) {
if (tankFluid.amount == recipeFluid.amount) { if (tankFluid.amount == recipeFluid.amount) {
this.tank.setFluid(null); tank.setFluid(null);
} else { } else {
tankFluid.amount -= recipeFluid.amount; tankFluid.amount -= recipeFluid.amount;
} }
this.syncWithAll(); syncWithAll();
return true; return true;
} }
} }

View file

@ -56,7 +56,7 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP
} }
public boolean getMultiBlock() { public boolean getMultiBlock() {
return this.multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET); return multiblockChecker.checkRectY(1, 1, MultiblockChecker.REINFORCED_CASING, MultiblockChecker.ZERO_OFFSET);
} }
// TileGenericMachine // TileGenericMachine
@ -71,7 +71,7 @@ public class TileVacuumFreezer extends TileGenericMachine implements IContainerP
@Override @Override
public void validate() { public void validate() {
super.validate(); super.validate();
this.multiblockChecker = new MultiblockChecker(this.world, this.getPos().down()); multiblockChecker = new MultiblockChecker(world, pos.down());
} }
// IContainerProvider // IContainerProvider

View file

@ -365,10 +365,9 @@ public class TileAutoCraftingTable extends TilePowerAcceptor
if (canMake(recipe)) { if (canMake(recipe)) {
if (canUseEnergy(euTick)) { if (canUseEnergy(euTick)) {
progress++; progress++;
if(progress == 1){ if (progress == 1) {
world.playSound(null, pos.getX(), pos.getY(), world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.AUTO_CRAFTING,
pos.getZ(), ModSounds.AUTO_CRAFTING, SoundCategory.BLOCKS, 0.3F, 0.8F);
SoundCategory.BLOCKS, 0.3F, 0.8F);
} }
useEnergy(euTick); useEnergy(euTick);
} }

View file

@ -63,47 +63,50 @@ public class TileElectricFurnace extends TilePowerAcceptor
super(); super();
} }
public int gaugeProgressScaled(final int scale) { public int gaugeProgressScaled(int scale) {
return this.progress * scale / this.fuelScale; return progress * scale / fuelScale;
} }
public void cookItems() { public void cookItems() {
if (this.canSmelt()) { if (canSmelt()) {
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) { if (getStackInSlot(output) == ItemStack.EMPTY) {
this.setInventorySlotContents(this.output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (this.getStackInSlot(this.output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack)) {
this.getStackInSlot(this.output).grow(itemstack.getCount()); getStackInSlot(output).grow(itemstack.getCount());
} }
if (this.getStackInSlot(this.input1).getCount() > 1) { if (getStackInSlot(input1).getCount() > 1) {
this.decrStackSize(this.input1, 1); decrStackSize(input1, 1);
} else { } else {
this.setInventorySlotContents(this.input1, ItemStack.EMPTY); setInventorySlotContents(input1, ItemStack.EMPTY);
} }
} }
} }
public boolean canSmelt() { public boolean canSmelt() {
if (this.getStackInSlot(this.input1) == ItemStack.EMPTY) { if (getStackInSlot(input1) == ItemStack.EMPTY) {
return false; return false;
} }
final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.getStackInSlot(this.input1)); final ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack.isEmpty()) if (itemstack.isEmpty()) {
return false; return false;
if (this.getStackInSlot(this.output) == ItemStack.EMPTY) }
if (getStackInSlot(output) == ItemStack.EMPTY) {
return true; return true;
if (!this.getStackInSlot(this.output).isItemEqual(itemstack)) }
if (!getStackInSlot(output).isItemEqual(itemstack)) {
return false; return false;
final int result = this.getStackInSlot(this.output).getCount() + itemstack.getCount(); }
final int result = getStackInSlot(output).getCount() + itemstack.getCount();
return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize(); return result <= this.getInventoryStackLimit() && result <= itemstack.getMaxStackSize();
} }
public boolean isBurning() { public boolean isBurning() {
return this.getEnergy() > getEuPerTick(this.cost); return getEnergy() > getEuPerTick(cost);
} }
public ItemStack getResultFor(final ItemStack stack) { public ItemStack getResultFor(ItemStack stack) {
final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack); final ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (!result.isEmpty()) { if (!result.isEmpty()) {
return result.copy(); return result.copy();
@ -112,26 +115,26 @@ public class TileElectricFurnace extends TilePowerAcceptor
} }
public void updateState() { public void updateState() {
if (wasBurning != (this.progress > 0)) { if (wasBurning != (progress > 0)) {
// skips updating the block state for 1 tick, to prevent the machine from // skips updating the block state for 1 tick, to prevent the machine from
// turning on/off rapidly causing fps drops // turning on/off rapidly causing fps drops
if (wasBurning && this.progress == 0 && canSmelt()) { if (wasBurning && progress == 0 && canSmelt()) {
wasBurning = true; wasBurning = true;
return; return;
} }
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos); final IBlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != this.progress > 0) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(this.progress > 0, this.world, this.pos); blockMachineBase.setActive(progress > 0, world, pos);
} }
wasBurning = (this.progress > 0); wasBurning = (progress > 0);
} }
} }
public int getBurnTime() { public int getBurnTime() {
return this.progress; return progress;
} }
public void setBurnTime(final int burnTime) { public void setBurnTime(final int burnTime) {
@ -146,32 +149,31 @@ public class TileElectricFurnace extends TilePowerAcceptor
} }
super.update(); super.update();
this.charge(2); charge(2);
final boolean burning = this.isBurning(); final boolean burning = isBurning();
boolean updateInventory = false; boolean updateInventory = false;
if (this.isBurning() && this.canSmelt()) { if (isBurning() && canSmelt()) {
this.updateState(); updateState();
if (canUseEnergy(getEuPerTick(this.cost))) { if (canUseEnergy(getEuPerTick(cost))) {
this.useEnergy(getEuPerTick(this.cost)); useEnergy(getEuPerTick(cost));
this.progress++; progress++;
if (this.progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 5)) { if (progress >= Math.max((int) (fuelScale * (1.0 - getSpeedMultiplier())), 5)) {
this.progress = 0; progress = 0;
this.cookItems(); cookItems();
updateInventory = true; updateInventory = true;
} }
} }
} else { } else {
this.progress = 0; progress = 0;
this.updateState(); updateState();
} }
if (burning != this.isBurning()) { if (burning != isBurning()) {
updateInventory = true; updateInventory = true;
} }
if (updateInventory) { if (updateInventory) {
this.markDirty(); markDirty();
} }
} }
@Override @Override
@ -208,7 +210,7 @@ public class TileElectricFurnace extends TilePowerAcceptor
// IInventoryProvider // IInventoryProvider
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return inventory;
} }
// IContainerProvider // IContainerProvider

View file

@ -91,8 +91,8 @@ public class TilePlayerDectector extends TilePowerAcceptor implements IToolDrop
useEnergy(euPerTick); useEnergy(euPerTick);
} }
if (lastRedstone != redstone) { if (lastRedstone != redstone) {
WorldUtils.updateBlock(world, getPos()); WorldUtils.updateBlock(world, pos);
world.notifyNeighborsOfStateChange(getPos(), world.getBlockState(getPos()).getBlock(), true); world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock(), true);
} }
} }
} }

View file

@ -62,59 +62,62 @@ public class TileRecycler extends TilePowerAcceptor
super(); super();
} }
public int gaugeProgressScaled(final int scale) { public int gaugeProgressScaled(int scale) {
return this.progress * scale / this.time; return progress * scale / time;
} }
public int getProgress() { public int getProgress() {
return this.progress; return progress;
} }
public void setProgress(final int progress) { public void setProgress(int progress) {
this.progress = progress; this.progress = progress;
} }
public void recycleItems() { public void recycleItems() {
final ItemStack itemstack = ItemParts.getPartByName("scrap"); final ItemStack itemstack = ItemParts.getPartByName("scrap");
final int randomchance = this.world.rand.nextInt(this.chance); final int randomchance = this.world.rand.nextInt(chance);
if (randomchance == 1) { if (randomchance == 1) {
if (this.getStackInSlot(1).isEmpty()) if (getStackInSlot(1).isEmpty()) {
this.setInventorySlotContents(1, itemstack.copy()); setInventorySlotContents(1, itemstack.copy());
else }
else {
this.getStackInSlot(1).grow(itemstack.getCount()); this.getStackInSlot(1).grow(itemstack.getCount());
}
} }
this.decrStackSize(0, 1); decrStackSize(0, 1);
} }
public boolean canRecycle() { public boolean canRecycle() {
return this.getStackInSlot(0) != ItemStack.EMPTY && this.hasSlotGotSpace(1); return getStackInSlot(0) != ItemStack.EMPTY && hasSlotGotSpace(1);
} }
public boolean hasSlotGotSpace(final int slot) { public boolean hasSlotGotSpace(int slot) {
if (this.getStackInSlot(slot) == ItemStack.EMPTY) { if (getStackInSlot(slot) == ItemStack.EMPTY) {
return true; return true;
} else if (this.getStackInSlot(slot).getCount() < this.getStackInSlot(slot).getMaxStackSize()) { } else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
return true; return true;
} }
return false; return false;
} }
public boolean isBurning() { public boolean isBurning() {
return this.isBurning; return isBurning;
} }
public void setBurning(final boolean burning) { public void setBurning(boolean burning) {
this.isBurning = burning; this.isBurning = burning;
} }
public void updateState() { public void updateState() {
final IBlockState BlockStateContainer = this.world.getBlockState(this.pos); final IBlockState BlockStateContainer = world.getBlockState(pos);
if (BlockStateContainer.getBlock() instanceof BlockMachineBase) { if (BlockStateContainer.getBlock() instanceof BlockMachineBase) {
final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock(); final BlockMachineBase blockMachineBase = (BlockMachineBase) BlockStateContainer.getBlock();
boolean shouldBurn = this.isBurning || (this.canRecycle() && this.canUseEnergy(getEuPerTick(this.cost))); boolean shouldBurn = isBurning || (canRecycle() && canUseEnergy(getEuPerTick(cost)));
if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != shouldBurn) if (BlockStateContainer.getValue(BlockMachineBase.ACTIVE) != shouldBurn) {
blockMachineBase.setActive(this.isBurning, this.world, this.pos); blockMachineBase.setActive(isBurning, world, pos);
}
} }
} }
@ -122,29 +125,32 @@ public class TileRecycler extends TilePowerAcceptor
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if (this.world.isRemote) if (world.isRemote) {
return; return;
}
charge(2);
boolean updateInventory = false; boolean updateInventory = false;
if (this.canRecycle() && !this.isBurning() && this.getEnergy() != 0) if (canRecycle() && !isBurning() && getEnergy() != 0) {
this.setBurning(true); setBurning(true);
else if (this.isBurning()) { }
if (this.useEnergy(getEuPerTick(this.cost)) != getEuPerTick(this.cost)) else if (isBurning()) {
if (useEnergy(getEuPerTick(cost)) != getEuPerTick(cost)) {
this.setBurning(false); this.setBurning(false);
this.progress++; }
if (this.progress >= Math.max((int) (this.time* (1.0 - getSpeedMultiplier())), 1)) { progress++;
this.progress = 0; if (progress >= Math.max((int) (time* (1.0 - getSpeedMultiplier())), 1)) {
this.recycleItems(); progress = 0;
recycleItems();
updateInventory = true; updateInventory = true;
this.setBurning(false); setBurning(false);
} }
} }
this.updateState(); updateState();
this.charge(2);
if (updateInventory) { if (updateInventory) {
this.markDirty(); markDirty();
} }
} }
@ -154,12 +160,12 @@ public class TileRecycler extends TilePowerAcceptor
} }
@Override @Override
public boolean canAcceptEnergy(final EnumFacing direction) { public boolean canAcceptEnergy(EnumFacing direction) {
return true; return true;
} }
@Override @Override
public boolean canProvideEnergy(final EnumFacing direction) { public boolean canProvideEnergy(EnumFacing direction) {
return false; return false;
} }
@ -181,7 +187,7 @@ public class TileRecycler extends TilePowerAcceptor
// IToolDrop // IToolDrop
@Override @Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) { public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.RECYCLER, 1); return new ItemStack(ModBlocks.RECYCLER, 1);
} }
@ -193,7 +199,7 @@ public class TileRecycler extends TilePowerAcceptor
// IContainerProvider // IContainerProvider
@Override @Override
public BuiltContainer createContainer(final EntityPlayer player) { public BuiltContainer createContainer(EntityPlayer player) {
return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory() return new ContainerBuilder("recycler").player(player.inventory).inventory().hotbar().addInventory()
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue() .tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).energySlot(2, 8, 72).syncEnergyValue()
.syncIntegerValue(this::getProgress, this::setProgress).addInventory().create(this); .syncIntegerValue(this::getProgress, this::setProgress).addInventory().create(this);

View file

@ -112,64 +112,69 @@ public class TileRollingMachine extends TilePowerAcceptor
@Override @Override
public void update() { public void update() {
super.update(); super.update();
this.charge(2); if (world.isRemote) {
if (!this.world.isRemote) { return;
InventoryCrafting craftMatrix = getCraftingMatrix(); }
this.currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, this.world); charge(2);
if (this.currentRecipe != null) {
if (world.getTotalWorldTime() % 2 == 0) {
Optional<InventoryCrafting> balanceResult = balanceRecipe(craftMatrix);
if (balanceResult.isPresent()) {
craftMatrix = balanceResult.get();
}
}
this.currentRecipeOutput = currentRecipe.getCraftingResult(craftMatrix);
} else {
this.currentRecipeOutput = ItemStack.EMPTY;
}
if (!this.currentRecipeOutput.isEmpty() && this.canMake(craftMatrix)) { InventoryCrafting craftMatrix = getCraftingMatrix();
if (this.tickTime >= Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1)) { currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world);
this.currentRecipeOutput = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, this.world); if (currentRecipe != null) {
if (!this.currentRecipeOutput.isEmpty()) { if (world.getTotalWorldTime() % 2 == 0) {
boolean hasCrafted = false; Optional<InventoryCrafting> balanceResult = balanceRecipe(craftMatrix);
if (this.inventory.getStackInSlot(outputSlot) == ItemStack.EMPTY) { if (balanceResult.isPresent()) {
this.inventory.setInventorySlotContents(outputSlot, this.currentRecipeOutput); craftMatrix = balanceResult.get();
this.tickTime = 0; }
}
currentRecipeOutput = currentRecipe.getCraftingResult(craftMatrix);
} else {
currentRecipeOutput = ItemStack.EMPTY;
}
if (!currentRecipeOutput.isEmpty() && canMake(craftMatrix)) {
if (tickTime >= Math.max((int) (runTime * (1.0 - getSpeedMultiplier())), 1)) {
currentRecipeOutput = RollingMachineRecipe.instance.findMatchingRecipeOutput(craftMatrix, world);
if (!currentRecipeOutput.isEmpty()) {
boolean hasCrafted = false;
if (inventory.getStackInSlot(outputSlot) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(outputSlot, currentRecipeOutput);
tickTime = 0;
hasCrafted = true;
} else {
if (inventory.getStackInSlot(outputSlot).getCount()
+ currentRecipeOutput.getCount() <= currentRecipeOutput.getMaxStackSize()) {
final ItemStack stack = inventory.getStackInSlot(outputSlot);
stack.setCount(stack.getCount() + currentRecipeOutput.getCount());
inventory.setInventorySlotContents(outputSlot, stack);
tickTime = 0;
hasCrafted = true; hasCrafted = true;
} else {
if (this.inventory.getStackInSlot(outputSlot).getCount() + this.currentRecipeOutput.getCount() <= this.currentRecipeOutput
.getMaxStackSize()) {
final ItemStack stack = this.inventory.getStackInSlot(outputSlot);
stack.setCount(stack.getCount() + this.currentRecipeOutput.getCount());
this.inventory.setInventorySlotContents(outputSlot, stack);
this.tickTime = 0;
hasCrafted = true;
}
}
if (hasCrafted) {
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
inventory.decrStackSize(i, 1);
}
this.currentRecipeOutput = ItemStack.EMPTY;
this.currentRecipe = null;
} }
} }
} if (hasCrafted) {
} else { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
this.tickTime = 0; inventory.decrStackSize(i, 1);
} }
if (!this.currentRecipeOutput.isEmpty()) { currentRecipeOutput = ItemStack.EMPTY;
if (this.canUseEnergy(getEuPerTick(energyPerTick)) && this.tickTime < Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1) && canMake(craftMatrix)) { currentRecipe = null;
this.useEnergy(getEuPerTick(energyPerTick)); }
this.tickTime++;
} }
} }
if (this.currentRecipeOutput.isEmpty()) { } else {
this.tickTime = 0; tickTime = 0;
this.currentRecipe = null; }
if (!currentRecipeOutput.isEmpty()) {
if (canUseEnergy(getEuPerTick(energyPerTick))
&& tickTime < Math.max((int) (runTime * (1.0 - getSpeedMultiplier())), 1)
&& canMake(craftMatrix)) {
useEnergy(getEuPerTick(energyPerTick));
tickTime++;
} }
} }
if (currentRecipeOutput.isEmpty()) {
tickTime = 0;
currentRecipe = null;
}
} }
public Optional<InventoryCrafting> balanceRecipe(InventoryCrafting craftCache) { public Optional<InventoryCrafting> balanceRecipe(InventoryCrafting craftCache) {
@ -301,11 +306,11 @@ public class TileRollingMachine extends TilePowerAcceptor
@Override @Override
public Inventory getInventory() { public Inventory getInventory() {
return this.inventory; return inventory;
} }
public int getBurnTime() { public int getBurnTime() {
return this.tickTime; return tickTime;
} }
public void setBurnTime(final int burnTime) { public void setBurnTime(final int burnTime) {
@ -313,10 +318,10 @@ public class TileRollingMachine extends TilePowerAcceptor
} }
public int getBurnTimeRemainingScaled(final int scale) { public int getBurnTimeRemainingScaled(final int scale) {
if (this.tickTime == 0 || Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1) == 0) { if (tickTime == 0 || Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1) == 0) {
return 0; return 0;
} }
return this.tickTime * scale / Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1); return tickTime * scale / Math.max((int) (runTime* (1.0 - getSpeedMultiplier())), 1);
} }
@Override @Override

View file

@ -134,7 +134,7 @@ public class TileTransformer extends TilePowerAcceptor
// IToolDrop // IToolDrop
@Override @Override
public ItemStack getToolDrop(EntityPlayer p0) { public ItemStack getToolDrop(EntityPlayer playerIn) {
return new ItemStack(wrenchDrop); return new ItemStack(wrenchDrop);
} }