Got the Vacuum Freezer working.

This commit is contained in:
Modmuss50 2015-11-18 08:35:34 +00:00
parent 8fd59c896b
commit 758d918bdb
5 changed files with 64 additions and 5 deletions

View file

@ -24,7 +24,9 @@ public class VacuumFreezerRecipe extends BaseRecipe {
@Override
public boolean canCraft(TileEntity tile) {
if(tile instanceof TileVacuumFreezer){
return ((TileVacuumFreezer) tile).multiBlockStatus == 1;
if(((TileVacuumFreezer) tile).multiBlockStatus == 1){
return true;
}
}
return false;
}

View file

@ -1,16 +1,22 @@
package techreborn.client;
import net.minecraftforge.common.util.ForgeDirection;
import reborncore.client.multiblock.Multiblock;
import techreborn.init.ModBlocks;
public class ClientMultiBlocks {
public static Multiblock reactor;
public static Multiblock frezzer;
public static void init(){
reactor = new Multiblock();
checkCoils();
frezzer = new Multiblock();
checkMachine();
}
public static void checkCoils() {
@ -46,4 +52,19 @@ public class ClientMultiBlocks {
return true;
}
public static void checkMachine() {
int xDir = ForgeDirection.UP.offsetX * 2;
int yDir = ForgeDirection.UP.offsetY * 2;
int zDir = ForgeDirection.UP.offsetZ * 2;
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
for (int k = -1; k < 2; k++) {
if ((i != 0) || (j != 0) || (k != 0)) {
reactor.addComponent(xDir + i, yDir + j, zDir + k, ModBlocks.MachineCasing, (((i == 0) && (j == 0) && (k != 0)) || ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2 : 1));
}
}
}
}
}
}

View file

@ -68,6 +68,7 @@ public class ContainerVacuumFreezer extends ContainerCrafting {
@SideOnly(Side.CLIENT)
@Override
public void updateProgressBar(int id, int value) {
super.updateProgressBar(id, value);
if (id == 3) {
machineStatus = value;
}

View file

@ -1,12 +1,19 @@
package techreborn.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import reborncore.client.gui.GuiUtil;
import reborncore.client.multiblock.MultiblockSet;
import reborncore.common.misc.Location;
import techreborn.client.ClientMultiBlocks;
import techreborn.client.container.ContainerVacuumFreezer;
import techreborn.proxies.ClientProxy;
import techreborn.tiles.TileVacuumFreezer;
public class GuiVacuumFreezer extends GuiContainer {
@ -28,7 +35,16 @@ public class GuiVacuumFreezer extends GuiContainer {
public void initGui() {
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
GuiButton button = new GuiButton(212, k + this.xSize - 24, l + 4, 20, 20, "");
buttonList.add(button);
super.initGui();
ChunkCoordinates coordinates = new ChunkCoordinates(crafter.xCoord, crafter.yCoord - 1, crafter.zCoord);
if(coordinates.equals(ClientProxy.multiblockRenderEvent.anchor)){
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
} else {
button.displayString = "A";
}
}
@Override
@ -42,7 +58,7 @@ public class GuiVacuumFreezer extends GuiContainer {
j = crafter.getProgressScaled(24);
if (j > 0) {
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, j + 1, 16);
this.drawTexturedModalRect(k + 79, l + 37, 176, 14, j + 1, 16);
}
j = crafter.getEnergyScaled(12);
@ -61,4 +77,23 @@ public class GuiVacuumFreezer extends GuiContainer {
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}
@Override
public void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if(button.id == 212){
if(ClientProxy.multiblockRenderEvent.currentMultiblock == null){
{//This code here makes a basic multiblock and then sets to the selected one.
MultiblockSet set = new MultiblockSet(ClientMultiBlocks.frezzer);
ClientProxy.multiblockRenderEvent.setMultiblock(set);
ClientProxy.multiblockRenderEvent.partent = new Location(crafter.xCoord, crafter.yCoord, crafter.zCoord, crafter.getWorldObj());
ClientProxy.multiblockRenderEvent.anchor = new ChunkCoordinates(crafter.xCoord , crafter.yCoord -1 , crafter.zCoord);
}
button.displayString = "A";
} else {
ClientProxy.multiblockRenderEvent.setMultiblock(null);
button.displayString = "B";
}
}
}
}

View file

@ -25,7 +25,7 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
outputs[0] = 0;
outputs[0] = 1;
crafter = new RecipeCrafter(Reference.vacuumFreezerRecipe, this, 2, 1, inventory, inputs, outputs);
}
@ -193,10 +193,10 @@ public class TileVacuumFreezer extends TilePowerAcceptor implements IWrenchable,
if (worldObj.getBlock(xCoord - xDir + i, yCoord - yDir + j, zCoord - zDir + k) != ModBlocks.MachineCasing) {
return false;
}
if (worldObj.getBlockMetadata(xCoord - xDir + i, yCoord - yDir + j, zCoord - zDir + k) != (((i == 0) && (j == 0) && (k != 0)) || ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 1 : 2)) {
if (worldObj.getBlockMetadata(xCoord - xDir + i, yCoord - yDir + j, zCoord - zDir + k) != (((i == 0) && (j == 0) && (k != 0)) || ((i == 0) && (j != 0) && (k == 0)) || ((i != 0) && (j == 0) && (k == 0)) ? 2 : 1)) {
return false;
}
} else if (worldObj.getBlockMetadata(xCoord - xDir + i, yCoord - yDir + j, zCoord - zDir + k) != 0) {
} else if (!worldObj.isAirBlock(xCoord - xDir + i, yCoord - yDir + j, zCoord - zDir + k)) {
return false;
}
}