Generator logic
This commit is contained in:
parent
c8453292b4
commit
b61acffc68
4 changed files with 108 additions and 32 deletions
|
@ -1,8 +1,11 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnaceFuel;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.generator.TileGenerator;
|
||||
|
||||
|
@ -12,6 +15,10 @@ public class ContainerGenerator extends RebornContainer {
|
|||
|
||||
TileGenerator tile;
|
||||
|
||||
public int burnTime = 0;
|
||||
public int totalBurnTime = 0;
|
||||
public int energy;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
|
@ -45,4 +52,46 @@ public class ContainerGenerator extends RebornContainer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.burnTime != tile.burnTime) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, tile.burnTime);
|
||||
}
|
||||
if (this.totalBurnTime != tile.totalBurnTime) {
|
||||
icrafting.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
|
||||
}
|
||||
if (this.energy != (int) tile.getEnergy()) {
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened(ICrafting crafting) {
|
||||
super.onCraftGuiOpened(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.burnTime);
|
||||
crafting.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.burnTime = value;
|
||||
} else if (id == 1) {
|
||||
this.totalBurnTime = value;
|
||||
} else if (id == 2) {
|
||||
this.energy = value;
|
||||
}
|
||||
this.tile.setEnergy(energy);
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int i) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * i);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue