Moved over to the vanilla packet system.
This commit is contained in:
parent
3b56d7c1e1
commit
c5e73c6fc3
5 changed files with 74 additions and 19 deletions
|
@ -77,10 +77,6 @@ public class GuiHandler implements IGuiHandler {
|
|||
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
|
||||
int x, int y, int z)
|
||||
{
|
||||
|
||||
if(world.getTileEntity(x, y, z) instanceof TileMachineBase){
|
||||
((TileMachineBase) world.getTileEntity(x, y, z)).syncWithAll();
|
||||
}
|
||||
if (ID == thermalGeneratorID)
|
||||
{
|
||||
return new ContainerThermalGenerator(
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
|
||||
public abstract class ContainerCrafting extends TechRebornContainer {
|
||||
|
||||
RecipeCrafter crafter;
|
||||
|
||||
public int currentTickTime = 0;
|
||||
public int currentNeededTicks = 0;
|
||||
public int energy;
|
||||
|
||||
public ContainerCrafting(RecipeCrafter crafter) {
|
||||
this.crafter = crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting)this.crafters.get(i);
|
||||
if(this.currentTickTime != crafter.currentTickTime){
|
||||
icrafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime);
|
||||
}
|
||||
if(this.currentNeededTicks != crafter.currentNeededTicks){
|
||||
icrafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks);
|
||||
}
|
||||
if(this.energy != (int)crafter.energy.getEnergyStored()){
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergyStored());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime);
|
||||
crafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks);
|
||||
crafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergyStored());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if(id == 0){
|
||||
this.currentTickTime = value;
|
||||
} else if(id == 1){
|
||||
this.currentNeededTicks = value;
|
||||
} else if(id == 2){
|
||||
this.energy = value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import net.minecraft.inventory.Slot;
|
|||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileImplosionCompressor;
|
||||
|
||||
public class ContainerImplosionCompressor extends TechRebornContainer{
|
||||
public class ContainerImplosionCompressor extends ContainerCrafting{
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
@ -17,6 +17,7 @@ public class ContainerImplosionCompressor extends TechRebornContainer{
|
|||
public ContainerImplosionCompressor(TileImplosionCompressor tilecompressor,
|
||||
EntityPlayer player)
|
||||
{
|
||||
super(tilecompressor.crafter);
|
||||
tile = tilecompressor;
|
||||
this.player = player;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import net.minecraft.client.resources.I18n;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.client.container.ContainerCrafting;
|
||||
import techreborn.client.container.ContainerImplosionCompressor;
|
||||
import techreborn.tiles.TileImplosionCompressor;
|
||||
|
||||
|
@ -14,9 +15,11 @@ public class GuiImplosionCompressor extends GuiContainer{
|
|||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/implosion_compressor.png");
|
||||
|
||||
TileImplosionCompressor compresser;
|
||||
ContainerImplosionCompressor containerImplosionCompressor;
|
||||
|
||||
public GuiImplosionCompressor(EntityPlayer player, TileImplosionCompressor tilecompresser) {
|
||||
super(new ContainerImplosionCompressor(tilecompresser, player));
|
||||
containerImplosionCompressor = (ContainerImplosionCompressor) this.inventorySlots;
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
compresser = tilecompresser;
|
||||
|
@ -38,14 +41,17 @@ public class GuiImplosionCompressor extends GuiContainer{
|
|||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
int j = 0;
|
||||
if(this.containerImplosionCompressor.currentTickTime != 0){
|
||||
j = this.containerImplosionCompressor.currentTickTime * 20 / this.containerImplosionCompressor.currentNeededTicks;
|
||||
}
|
||||
|
||||
|
||||
System.out.println(this.containerImplosionCompressor.currentTickTime);
|
||||
|
||||
if(compresser.crafter.currentRecipe != null) {
|
||||
j = this.compresser.crafter.currentTickTime * 20 / this.compresser.crafter.currentRecipe.tickTime();
|
||||
}
|
||||
this.drawTexturedModalRect(k + 60, l + 38, 176, 14, j + 1, 16);
|
||||
|
||||
j = (int)this.compresser.energy.getEnergyStored() * 12 / this.compresser.energy.getCapacity();
|
||||
j = this.containerImplosionCompressor.energy * 12 / this.compresser.energy.getCapacity();
|
||||
if(j > 0) {
|
||||
this.drawTexturedModalRect(k + 16, l + 37 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue