Added basic fustion reactor multiblock checking.

This commit is contained in:
Modmuss50 2015-11-16 15:20:13 +00:00
parent 962a165249
commit f42c127201
9 changed files with 288 additions and 61 deletions

View file

@ -7,6 +7,7 @@ import techreborn.client.container.*;
import techreborn.client.gui.*;
import techreborn.pda.GuiManual;
import techreborn.tiles.*;
import techreborn.tiles.fusionReactor.TileEntityFusionController;
import techreborn.tiles.idsu.TileIDSU;
import techreborn.tiles.lesu.TileLesu;
@ -38,7 +39,7 @@ public class GuiHandler implements IGuiHandler {
public static final int lesuID = 26;
public static final int idsuID = 27;
public static final int chargeBench = 28;
public static final int farmID = 29;
public static final int fusionID = 29;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
@ -116,6 +117,8 @@ public class GuiHandler implements IGuiHandler {
return new ContainerIDSU((TileIDSU) world.getTileEntity(x, y, z), player);
} else if (ID == chargeBench) {
return new ContainerChargeBench((TileChargeBench) world.getTileEntity(x, y, z), player);
} else if (ID == fusionID) {
return new ContainerFusionReactor((TileEntityFusionController) world.getTileEntity(x, y, z), player);
}
@ -198,6 +201,8 @@ public class GuiHandler implements IGuiHandler {
return new GuiIDSU(player, (TileIDSU) world.getTileEntity(x, y, z));
} else if (ID == chargeBench) {
return new GuiChargeBench(player, (TileChargeBench) world.getTileEntity(x, y, z));
}else if (ID == fusionID) {
return new GuiFusionReactor(player, (TileEntityFusionController) world.getTileEntity(x, y, z));
}
return null;
}

View file

@ -0,0 +1,80 @@
package techreborn.client.container;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import reborncore.client.gui.SlotOutput;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.fusionReactor.TileEntityFusionController;
public class ContainerFusionReactor extends RebornContainer {
public int coilStatus;
public int energy;
TileEntityFusionController fusionController;
public ContainerFusionReactor(TileEntityFusionController tileEntityFusionController,
EntityPlayer player) {
super();
this.fusionController = tileEntityFusionController;
addSlotToContainer(new Slot(tileEntityFusionController, 0, 88, 17));
addSlotToContainer(new Slot(tileEntityFusionController, 1, 88, 53));
addSlotToContainer(new SlotOutput(tileEntityFusionController, 2, 148, 35));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (int i = 0; i < this.crafters.size(); i++) {
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.coilStatus != fusionController.coilStatus) {
icrafting.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
}
if (this.energy != (int) fusionController.getEnergy()) {
icrafting.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
}
}
}
@Override
public void addCraftingToCrafters(ICrafting crafting) {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, fusionController.coilStatus);
crafting.sendProgressBarUpdate(this, 1, (int) fusionController.getEnergy());
}
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
if (id == 0) {
this.coilStatus = value;
} else if (id == 1) {
this.energy = value;
}
}
}

View file

@ -1,18 +0,0 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.fusionReactor.TileEntityFustionController;
public class ContainerFustionReactor extends RebornContainer {
public ContainerFustionReactor(TileEntityFustionController tileEntityFustionController,
EntityPlayer player) {
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}

View file

@ -2,17 +2,23 @@ package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.inventory.Container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import techreborn.client.container.ContainerFusionReactor;
import techreborn.tiles.fusionReactor.TileEntityFusionController;
public class GuiFusionReactor extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/fusion_reactor.png");
public GuiFusionReactor(Container container) {
super(container);
ContainerFusionReactor containerFusionReactor;
public GuiFusionReactor(EntityPlayer player,
TileEntityFusionController tileaesu) {
super(new ContainerFusionReactor(tileaesu, player));
containerFusionReactor = (ContainerFusionReactor) this.inventorySlots;
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
@ -20,8 +26,8 @@ public class GuiFusionReactor extends GuiContainer {
this.fontRendererObj.drawString(name, 87, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString("EU: xxxx", 11, 8, 16448255);
this.fontRendererObj.drawString("Coils: " + "Yes" , 11, 16, 16448255);
this.fontRendererObj.drawString("EU: " + containerFusionReactor.energy, 11, 8, 16448255);
this.fontRendererObj.drawString("Coils: " + (containerFusionReactor.coilStatus == 1 ? "Yes" : "No") , 11, 16, 16448255);
}
@Override