mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
sold(i)er TF2
This commit is contained in:
parent
1f94b6b7a6
commit
41f9b41ef9
@ -5,6 +5,7 @@ import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSolderingStation;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -19,6 +20,11 @@ public class MachineSolderingStation extends BlockDummyable {
|
||||
if(meta >= 12) return new TileEntityMachineSolderingStation();
|
||||
return new TileEntityProxyCombo().inventory().power().fluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
return this.standardOpenBehavior(world, x, y, z, player, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDimensions() {
|
||||
|
||||
@ -16,10 +16,10 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineArcWelder extends Container {
|
||||
|
||||
private TileEntityMachineArcWelder welder;
|
||||
private TileEntityMachineArcWelder solderer;
|
||||
|
||||
public ContainerMachineArcWelder(InventoryPlayer playerInv, TileEntityMachineArcWelder tile) {
|
||||
welder = tile;
|
||||
solderer = tile;
|
||||
|
||||
//Inputs
|
||||
this.addSlotToContainer(new Slot(tile, 0, 17, 36));
|
||||
@ -48,7 +48,7 @@ public class ContainerMachineArcWelder extends Container {
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return welder.isUseableByPlayer(player);
|
||||
return solderer.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotCraftingOutput;
|
||||
import com.hbm.inventory.SlotUpgrade;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSolderingStation;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineSolderingStation extends Container {
|
||||
|
||||
private TileEntityMachineSolderingStation welder;
|
||||
|
||||
public ContainerMachineSolderingStation(InventoryPlayer playerInv, TileEntityMachineSolderingStation tile) {
|
||||
welder = tile;
|
||||
|
||||
//Inputs
|
||||
for(int i = 0; i < 2; i++) for(int j = 0; j < 3; j++) this.addSlotToContainer(new Slot(tile, i * 3 + j, 17 + j * 18, 18 + i * 18));
|
||||
//Output
|
||||
this.addSlotToContainer(new SlotCraftingOutput(playerInv.player, tile, 6, 107, 27));
|
||||
//Battery
|
||||
this.addSlotToContainer(new Slot(tile, 7, 152, 72));
|
||||
//Fluid ID
|
||||
this.addSlotToContainer(new Slot(tile, 8, 17, 63));
|
||||
//Upgrades
|
||||
this.addSlotToContainer(new SlotUpgrade(tile, 9, 89, 63));
|
||||
this.addSlotToContainer(new SlotUpgrade(tile, 10, 107, 63));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 122 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 180));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return welder.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineSolderingStation;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSolderingStation;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineSolderingMachine extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_soldering_station.png");
|
||||
private TileEntityMachineSolderingStation solderer;
|
||||
|
||||
public GUIMachineSolderingMachine(InventoryPlayer playerInv, TileEntityMachineSolderingStation tile) {
|
||||
super(new ContainerMachineSolderingStation(playerInv, tile));
|
||||
|
||||
this.solderer = tile;
|
||||
this.xSize = 176;
|
||||
this.ySize = 204;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
solderer.tank.renderTankInfo(this, x, y, guiLeft + 35, guiTop + 63, 34, 16);
|
||||
this.drawElectricityInfo(this, x, y, guiLeft + 152, guiTop + 18, 16, 52, solderer.getPower(), solderer.getMaxPower());
|
||||
|
||||
this.drawCustomInfoStat(x, y, guiLeft + 78, guiTop + 67, 8, 8, guiLeft + 78, guiTop + 67, this.getUpgradeInfo(solderer));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.solderer.hasCustomInventoryName() ? this.solderer.getInventoryName() : I18n.format(this.solderer.getInventoryName());
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2 - 18, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float interp, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int p = (int) (solderer.power * 52 / solderer.maxPower);
|
||||
drawTexturedModalRect(guiLeft + 152, guiTop + 70 - p, 176, 52 - p, 16, p);
|
||||
|
||||
int i = solderer.progress * 33 / solderer.processTime;
|
||||
drawTexturedModalRect(guiLeft + 72, guiTop + 28, 192, 0, i, 14);
|
||||
|
||||
if(solderer.power >= solderer.consumption) {
|
||||
drawTexturedModalRect(guiLeft + 156, guiTop + 4, 176, 52, 9, 12);
|
||||
}
|
||||
|
||||
this.drawInfoPanel(guiLeft + 78, guiTop + 67, 8, 8, 8);
|
||||
solderer.tank.renderTank(guiLeft + 35, guiTop + 79, this.zLevel, 34, 16, 1);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
package com.hbm.inventory.recipes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.RecipesCommon.ComparableStack;
|
||||
import com.hbm.inventory.recipes.loader.SerializableRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemCircuit.EnumCircuitType;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SolderingRecipes extends SerializableRecipe {
|
||||
|
||||
public static List<SolderingRecipe> recipes = new ArrayList();
|
||||
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
|
||||
recipes.add(new SolderingRecipe(new ItemStack(ModItems.circuit, 1, EnumCircuitType.ANALOG.ordinal()), 100, 100,
|
||||
new AStack[] {
|
||||
new ComparableStack(ModItems.circuit, 3, EnumCircuitType.VACUUM_TUBE.ordinal()),
|
||||
new ComparableStack(ModItems.circuit, 2, EnumCircuitType.CAPACITOR.ordinal())},
|
||||
new AStack[] {
|
||||
new ComparableStack(ModItems.circuit, 4, EnumCircuitType.PCB.ordinal())},
|
||||
new AStack[] {}
|
||||
));
|
||||
}
|
||||
|
||||
public static SolderingRecipe getRecipe(ItemStack[] inputs) {
|
||||
|
||||
for(SolderingRecipe recipe : recipes) {
|
||||
if(matchesIngredients(new ItemStack[] {inputs[0], inputs[1], inputs[2]}, recipe.toppings) &&
|
||||
matchesIngredients(new ItemStack[] {inputs[3], inputs[4]}, recipe.pcb) &&
|
||||
matchesIngredients(new ItemStack[] {inputs[5]}, recipe.solder)) return recipe;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "hbmSoldering.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getRecipeObject() {
|
||||
return recipes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRecipes() {
|
||||
recipes.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readRecipe(JsonElement recipe) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeRecipe(Object obj, JsonWriter writer) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
public static class SolderingRecipe {
|
||||
|
||||
public AStack[] toppings;
|
||||
public AStack[] pcb;
|
||||
public AStack[] solder;
|
||||
public FluidStack fluid;
|
||||
public ItemStack output;
|
||||
public int duration;
|
||||
public long consumption;
|
||||
|
||||
public SolderingRecipe(ItemStack output, int duration, long consumption, FluidStack fluid, AStack[] toppings, AStack[] pcb, AStack[] solder) {
|
||||
this.toppings = toppings;
|
||||
this.pcb = pcb;
|
||||
this.solder = solder;
|
||||
this.fluid = fluid;
|
||||
this.output = output;
|
||||
this.duration = duration;
|
||||
this.consumption = consumption;
|
||||
}
|
||||
|
||||
public SolderingRecipe(ItemStack output, int duration, long consumption, AStack[] toppings, AStack[] pcb, AStack[] solder) {
|
||||
this(output, duration, consumption, null, toppings, pcb, solder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@ -66,6 +67,7 @@ public abstract class SerializableRecipe {
|
||||
recipeHandlers.add(new ElectrolyserFluidRecipes());
|
||||
recipeHandlers.add(new ElectrolyserMetalRecipes());
|
||||
recipeHandlers.add(new ArcWelderRecipes());
|
||||
recipeHandlers.add(new SolderingRecipes());
|
||||
recipeHandlers.add(new ExposureChamberRecipes());
|
||||
recipeHandlers.add(new AssemblerRecipes());
|
||||
|
||||
@ -339,4 +341,33 @@ public abstract class SerializableRecipe {
|
||||
writer.endArray();
|
||||
writer.setIndent(" ");
|
||||
}
|
||||
|
||||
public static boolean matchesIngredients(ItemStack[] inputs, AStack[] recipe) {
|
||||
|
||||
List<AStack> recipeList = new ArrayList();
|
||||
for(AStack ingredient : recipe) recipeList.add(ingredient);
|
||||
|
||||
for(int i = 0; i < inputs.length; i++) {
|
||||
ItemStack inputStack = inputs[i];
|
||||
|
||||
if(inputStack != null) {
|
||||
boolean hasMatch = false;
|
||||
Iterator<AStack> iterator = recipeList.iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
AStack recipeStack = iterator.next();
|
||||
|
||||
if(recipeStack.matchesRecipe(inputStack, true) && inputStack.stackSize >= recipeStack.stacksize) {
|
||||
hasMatch = true;
|
||||
recipeList.remove(recipeStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!hasMatch) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipeList.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@ -600,6 +600,7 @@ public class ModItems {
|
||||
|
||||
public static Item parts_legendary;
|
||||
|
||||
public static Item circuit;
|
||||
public static Item circuit_raw;
|
||||
public static Item circuit_aluminium;
|
||||
public static Item circuit_copper;
|
||||
@ -3092,6 +3093,7 @@ public class ModItems {
|
||||
|
||||
entanglement_kit = new ItemCustomLore().setUnlocalizedName("entanglement_kit").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":entanglement_kit");
|
||||
|
||||
circuit = new ItemCircuit().setUnlocalizedName("circuit").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit");
|
||||
circuit_raw = new Item().setUnlocalizedName("circuit_raw").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_raw");
|
||||
circuit_aluminium = new Item().setUnlocalizedName("circuit_aluminium").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_aluminium");
|
||||
circuit_copper = new Item().setUnlocalizedName("circuit_copper").setCreativeTab(MainRegistry.partsTab).setTextureName(RefStrings.MODID + ":circuit_copper");
|
||||
@ -6232,6 +6234,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(shimmer_handle, shimmer_handle.getUnlocalizedName());
|
||||
|
||||
//Circuits
|
||||
GameRegistry.registerItem(circuit, circuit.getUnlocalizedName());
|
||||
GameRegistry.registerItem(circuit_raw, circuit_raw.getUnlocalizedName());
|
||||
GameRegistry.registerItem(circuit_aluminium, circuit_aluminium.getUnlocalizedName());
|
||||
GameRegistry.registerItem(circuit_copper, circuit_copper.getUnlocalizedName());
|
||||
|
||||
24
src/main/java/com/hbm/items/machine/ItemCircuit.java
Normal file
24
src/main/java/com/hbm/items/machine/ItemCircuit.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.hbm.items.machine;
|
||||
|
||||
import com.hbm.items.ItemEnumMulti;
|
||||
|
||||
public class ItemCircuit extends ItemEnumMulti {
|
||||
|
||||
public ItemCircuit() {
|
||||
super(EnumCircuitType.class, true, true);
|
||||
}
|
||||
|
||||
public static enum EnumCircuitType {
|
||||
VACUUM_TUBE,
|
||||
CAPACITOR,
|
||||
CAPACITOR_TANTALIUM,
|
||||
PCB,
|
||||
CHIP,
|
||||
CHIP_BISMOID,
|
||||
ANALOG,
|
||||
BASIC,
|
||||
ADVANCED,
|
||||
CAPACITOR_BOARD,
|
||||
BISMOID,
|
||||
}
|
||||
}
|
||||
@ -49,6 +49,9 @@ public class RenderArcFurnace extends TileEntitySpecialRenderer implements IItem
|
||||
GL11.glTranslated(0, 2 * lift, 0);
|
||||
if(arc.isProgressing) GL11.glTranslated(0, 0, Math.sin((arc.getWorldObj().getTotalWorldTime() + interp)) * 0.005);
|
||||
ResourceManager.arc_furnace.renderPart("Lid");
|
||||
if(arc.electrodes[0] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring1");
|
||||
if(arc.electrodes[1] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring2");
|
||||
if(arc.electrodes[2] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring3");
|
||||
if(arc.electrodes[0] == arc.ELECTRODE_FRESH) ResourceManager.arc_furnace.renderPart("Electrode1");
|
||||
if(arc.electrodes[1] == arc.ELECTRODE_FRESH) ResourceManager.arc_furnace.renderPart("Electrode2");
|
||||
if(arc.electrodes[2] == arc.ELECTRODE_FRESH) ResourceManager.arc_furnace.renderPart("Electrode3");
|
||||
@ -60,9 +63,6 @@ public class RenderArcFurnace extends TileEntitySpecialRenderer implements IItem
|
||||
if(arc.electrodes[1] == arc.ELECTRODE_DEPLETED) ResourceManager.arc_furnace.renderPart("Electrode2Short");
|
||||
if(arc.electrodes[2] == arc.ELECTRODE_DEPLETED) ResourceManager.arc_furnace.renderPart("Electrode3Short");
|
||||
fullbright(false);
|
||||
if(arc.electrodes[0] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring1");
|
||||
if(arc.electrodes[1] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring2");
|
||||
if(arc.electrodes[2] != arc.ELECTRODE_NONE) ResourceManager.arc_furnace.renderPart("Ring3");
|
||||
|
||||
if(arc.electrodes[0] != arc.ELECTRODE_NONE) {
|
||||
GL11.glPushMatrix();
|
||||
@ -94,15 +94,21 @@ public class RenderArcFurnace extends TileEntitySpecialRenderer implements IItem
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private static float lastX;
|
||||
private static float lastY;
|
||||
|
||||
public static void fullbright(boolean on) {
|
||||
|
||||
if(on) {
|
||||
lastX = OpenGlHelper.lastBrightnessX;
|
||||
lastY = OpenGlHelper.lastBrightnessY;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
} else {
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastX, lastY);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@ -7,7 +7,7 @@ import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.render.util.RenderDecoItem;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcWelder;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSolderingStation;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
@ -40,16 +40,16 @@ public class RenderSolderingStation extends TileEntitySpecialRenderer implements
|
||||
bindTexture(ResourceManager.soldering_station_tex);
|
||||
ResourceManager.soldering_station.renderAll();
|
||||
|
||||
/*TileEntityMachineArcWelder welder = (TileEntityMachineArcWelder) tile;
|
||||
if(welder.display != null) {
|
||||
TileEntityMachineSolderingStation solderer = (TileEntityMachineSolderingStation) tile;
|
||||
if(solderer.display != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0.0625D * 2.5D, 1.125D, 0D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glRotatef(90, 0F, 1F, 0F);
|
||||
GL11.glRotatef(-90, 1F, 0F, 0F);
|
||||
|
||||
if(welder.display != null) {
|
||||
ItemStack stack = welder.display.copy();
|
||||
if(solderer.display != null) {
|
||||
ItemStack stack = solderer.display.copy();
|
||||
|
||||
EntityItem item = new EntityItem(null, 0.0D, 0.0D, 0.0D, stack);
|
||||
item.getEntityItem().stackSize = 1;
|
||||
@ -61,7 +61,7 @@ public class RenderSolderingStation extends TileEntitySpecialRenderer implements
|
||||
RenderItem.renderInFrame = false;
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@ -1,11 +1,57 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.UpgradeManager;
|
||||
import com.hbm.inventory.RecipesCommon.AStack;
|
||||
import com.hbm.inventory.container.ContainerMachineSolderingStation;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIMachineSolderingMachine;
|
||||
import com.hbm.inventory.recipes.SolderingRecipes;
|
||||
import com.hbm.inventory.recipes.SolderingRecipes.SolderingRecipe;
|
||||
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.IUpgradeInfoProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
public class TileEntityMachineSolderingStation extends TileEntityMachineBase {
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineSolderingStation extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardReceiver, IGUIProvider, IUpgradeInfoProvider {
|
||||
|
||||
public long power;
|
||||
public long maxPower = 2_000;
|
||||
public long consumption;
|
||||
|
||||
public int progress;
|
||||
public int processTime = 1;
|
||||
|
||||
public FluidTank tank;
|
||||
public ItemStack display;
|
||||
|
||||
public TileEntityMachineSolderingStation() {
|
||||
super(11);
|
||||
this.tank = new FluidTank(Fluids.NONE, 8_000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -16,5 +62,241 @@ public class TileEntityMachineSolderingStation extends TileEntityMachineBase {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.power = Library.chargeTEFromItems(slots, 7, this.getPower(), this.getMaxPower());
|
||||
this.tank.setType(8, slots);
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
if(tank.getTankType() != Fluids.NONE) this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
SolderingRecipe recipe = SolderingRecipes.getRecipe(new ItemStack[] {slots[0], slots[1], slots[2], slots[3], slots[4], slots[5]});
|
||||
long intendedMaxPower;
|
||||
|
||||
UpgradeManager.eval(slots, 6, 7);
|
||||
int redLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3);
|
||||
int blueLevel = Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 3);
|
||||
|
||||
if(recipe != null) {
|
||||
this.processTime = recipe.duration - (recipe.duration * redLevel / 6) + (recipe.duration * blueLevel / 3);
|
||||
this.consumption = recipe.consumption + (recipe.consumption * redLevel) - (recipe.consumption * blueLevel / 6);
|
||||
intendedMaxPower = recipe.consumption * 20;
|
||||
|
||||
if(canProcess(recipe)) {
|
||||
this.progress++;
|
||||
this.power -= this.consumption;
|
||||
|
||||
if(progress >= processTime) {
|
||||
this.progress = 0;
|
||||
this.consumeItems(recipe);
|
||||
|
||||
if(slots[6] == null) {
|
||||
slots[6] = recipe.output.copy();
|
||||
} else {
|
||||
slots[6].stackSize += recipe.output.stackSize;
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
NBTTagCompound dPart = new NBTTagCompound();
|
||||
dPart.setString("type", "tau");
|
||||
dPart.setByte("count", (byte) 3);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(dPart, xCoord + 0.5 - dir.offsetX * 0.5 + rot.offsetX * 0.5, yCoord + 1.125, zCoord + 0.5 - dir.offsetZ * 0.5 + rot.offsetZ * 0.5), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 25));
|
||||
}
|
||||
|
||||
} else {
|
||||
this.progress = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
this.progress = 0;
|
||||
this.consumption = 100;
|
||||
intendedMaxPower = 2000;
|
||||
}
|
||||
|
||||
this.maxPower = Math.max(intendedMaxPower, power);
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setLong("maxPower", maxPower);
|
||||
data.setLong("consumption", consumption);
|
||||
data.setInteger("progress", progress);
|
||||
data.setInteger("processTime", processTime);
|
||||
if(recipe != null) {
|
||||
data.setInteger("display", Item.getIdFromItem(recipe.output.getItem()));
|
||||
data.setInteger("displayMeta", recipe.output.getItemDamage());
|
||||
}
|
||||
this.tank.writeToNBT(data, "t");
|
||||
this.networkPack(data, 25);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canProcess(SolderingRecipe recipe) {
|
||||
|
||||
if(this.power < this.consumption) return false;
|
||||
|
||||
if(recipe.fluid != null) {
|
||||
if(this.tank.getTankType() != recipe.fluid.type) return false;
|
||||
if(this.tank.getFill() < recipe.fluid.fill) return false;
|
||||
}
|
||||
|
||||
if(slots[6] != null) {
|
||||
if(slots[6].getItem() != recipe.output.getItem()) return false;
|
||||
if(slots[6].getItemDamage() != recipe.output.getItemDamage()) return false;
|
||||
if(slots[6].stackSize + recipe.output.stackSize > slots[3].getMaxStackSize()) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void consumeItems(SolderingRecipe recipe) {
|
||||
|
||||
for(AStack aStack : recipe.toppings) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
if(aStack.matchesRecipe(stack, true) && stack.stackSize >= aStack.stacksize) { this.decrStackSize(i, aStack.stacksize); break; }
|
||||
}
|
||||
}
|
||||
|
||||
for(AStack aStack : recipe.pcb) {
|
||||
for(int i = 3; i < 5; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
if(aStack.matchesRecipe(stack, true) && stack.stackSize >= aStack.stacksize) { this.decrStackSize(i, aStack.stacksize); break; }
|
||||
}
|
||||
}
|
||||
|
||||
for(AStack aStack : recipe.solder) {
|
||||
for(int i = 5; i < 6; i++) {
|
||||
ItemStack stack = slots[i];
|
||||
if(aStack.matchesRecipe(stack, true) && stack.stackSize >= aStack.stacksize) { this.decrStackSize(i, aStack.stacksize); break; }
|
||||
}
|
||||
}
|
||||
|
||||
if(recipe.fluid != null) {
|
||||
this.tank.setFill(tank.getFill() - recipe.fluid.fill);
|
||||
}
|
||||
}
|
||||
|
||||
protected DirPos[] getConPos() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
return new DirPos[] {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
super.networkUnpack(nbt);
|
||||
|
||||
this.power = nbt.getLong("power");
|
||||
this.maxPower = nbt.getLong("maxPower");
|
||||
this.consumption = nbt.getLong("consumption");
|
||||
this.progress = nbt.getInteger("progress");
|
||||
this.processTime = nbt.getInteger("processTime");
|
||||
|
||||
if(nbt.hasKey("display")) {
|
||||
this.display = new ItemStack(Item.getItemById(nbt.getInteger("display")), 1, nbt.getInteger("displayMeta"));
|
||||
} else {
|
||||
this.display = null;
|
||||
}
|
||||
|
||||
this.tank.readFromNBT(nbt, "t");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return Math.max(Math.min(power, maxPower), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return new FluidTank[] {tank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] {tank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerMachineSolderingStation(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIMachineSolderingMachine(player.inventory, this);
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
||||
if(bb == null) {
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 1,
|
||||
yCoord,
|
||||
zCoord - 1,
|
||||
xCoord + 2,
|
||||
yCoord + 3,
|
||||
zCoord + 2
|
||||
);
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) {
|
||||
return type == UpgradeType.SPEED || type == UpgradeType.POWER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideInfo(UpgradeType type, int level, List<String> info, boolean extendedInfo) {
|
||||
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_soldering_station));
|
||||
if(type == UpgradeType.SPEED) {
|
||||
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_DELAY, "-" + (level * 100 / 6) + "%"));
|
||||
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "+" + (level * 100) + "%"));
|
||||
}
|
||||
if(type == UpgradeType.POWER) {
|
||||
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "-" + (level * 100 / 6) + "%"));
|
||||
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(this.KEY_DELAY, "+" + (level * 100 / 3) + "%"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel(UpgradeType type) {
|
||||
if(type == UpgradeType.SPEED) return 3;
|
||||
if(type == UpgradeType.POWER) return 3;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 332 B |
Loading…
x
Reference in New Issue
Block a user