mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
crushin' crushin' (the second)
This commit is contained in:
parent
d6a364515e
commit
f39b5a0e2c
@ -1839,7 +1839,7 @@ public class ModBlocks {
|
||||
machine_electric_furnace_on = new MachineElectricFurnace(true).setBlockName("machine_electric_furnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
|
||||
machine_arc_furnace_off = new MachineArcFurnace(false).setBlockName("machine_arc_furnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
machine_arc_furnace_on = new MachineArcFurnace(true).setBlockName("machine_arc_furnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
|
||||
machine_arc_furnace = new MachineArcFurnaceLarge().setBlockName("machine_arc_furnace").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
machine_arc_furnace = new MachineArcFurnaceLarge().setBlockName("machine_arc_furnace").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
machine_microwave = new MachineMicrowave(Material.iron).setBlockName("machine_microwave").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_microwave");
|
||||
|
||||
machine_battery_potato = new MachineBattery(Material.iron, 10_000).setBlockName("machine_battery_potato").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||
|
||||
@ -113,6 +113,7 @@ public class OreDictManager {
|
||||
public static final DictFrame LAPIS = new DictFrame("Lapis");
|
||||
public static final DictFrame REDSTONE = new DictFrame("Redstone");
|
||||
public static final DictFrame NETHERQUARTZ = new DictFrame("NetherQuartz");
|
||||
public static final DictFrame QUARTZ = new DictFrame("Quartz");
|
||||
public static final DictFrame DIAMOND = new DictFrame("Diamond");
|
||||
public static final DictFrame EMERALD = new DictFrame("Emerald");
|
||||
/*
|
||||
@ -324,6 +325,7 @@ public class OreDictManager {
|
||||
GOLD.plate(plate_gold).dust(powder_gold).ore(ore_gneiss_gold);
|
||||
LAPIS.dust(powder_lapis);
|
||||
NETHERQUARTZ.gem(Items.quartz).dust(powder_quartz).ore(Blocks.quartz_ore);
|
||||
QUARTZ.dust(powder_quartz);
|
||||
DIAMOND.dust(powder_diamond).ore(gravel_diamond, ore_sellafield_diamond);
|
||||
EMERALD.dust(powder_emerald).ore(ore_sellafield_emerald);
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.tileentity.machine.TileEntityMachineArcFurnaceLarge;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -23,7 +24,7 @@ public class ContainerMachineArcFurnaceLarge extends Container {
|
||||
//Upgrade
|
||||
this.addSlotToContainer(new Slot(tile, 4, 152, 108));
|
||||
//Inputs
|
||||
for(int i = 0; i < 4; i++) for(int j = 0; j < 5; j++) this.addSlotToContainer(new SlotNonRetarded(tile, 5 + j + i * 5, 44 + j * 18, 54 + i * 18));
|
||||
for(int i = 0; i < 4; i++) for(int j = 0; j < 5; j++) this.addSlotToContainer(new SlotArcFurnace(tile, 5 + j + i * 5, 44 + j * 18, 54 + i * 18));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
@ -45,4 +46,16 @@ public class ContainerMachineArcFurnaceLarge extends Container {
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return furnace.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public static class SlotArcFurnace extends SlotNonRetarded {
|
||||
|
||||
public SlotArcFurnace(IInventory inventory, int id, int x, int y) {
|
||||
super(inventory, id, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return this.getHasStack() ? this.getStack().stackSize : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,28 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineArcFurnaceLarge;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.packet.NBTControlPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcFurnaceLarge;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineArcFurnaceLarge extends GuiInfoContainer {
|
||||
@ -27,10 +41,24 @@ public class GUIMachineArcFurnaceLarge extends GuiInfoContainer {
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
drawStackInfo(arc.liquids, x, y, 152, 36);
|
||||
|
||||
this.drawElectricityInfo(this, x, y, guiLeft + 8, guiTop + 36, 7, 70, arc.getPower(), arc.getMaxPower());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int k) {
|
||||
super.mouseClicked(x, y, k);
|
||||
|
||||
if(this.checkClick(x, y, 151, 17, 18, 18)) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setBoolean("liquid", true);
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, arc.xCoord, arc.yCoord, arc.zCoord));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.arc.hasCustomInventoryName() ? this.arc.getInventoryName() : I18n.format(this.arc.getInventoryName());
|
||||
@ -43,11 +71,56 @@ public class GUIMachineArcFurnaceLarge extends GuiInfoContainer {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if(arc.liquidMode) drawTexturedModalRect(guiLeft + 151, guiTop + 17, 190, 18, 18, 18);
|
||||
if(arc.isProgressing) drawTexturedModalRect(guiLeft + 7, guiTop + 17, 190, 0, 18, 18);
|
||||
|
||||
int p = (int) (arc.power * 70 / arc.maxPower);
|
||||
drawTexturedModalRect(guiLeft + 8, guiTop + 106 - p, 176, 70 - p, 7, p);
|
||||
|
||||
int o = (int) (arc.progress * 70);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 106 - o, 183, 70 - o, 7, o);
|
||||
|
||||
drawStack(arc.liquids, arc.maxLiquid, 152, 106);
|
||||
}
|
||||
|
||||
protected void drawStackInfo(List<MaterialStack> stack, int mouseX, int mouseY, int x, int y) {
|
||||
List<String> list = new ArrayList();
|
||||
if(stack.isEmpty()) list.add(EnumChatFormatting.RED + "Empty");
|
||||
for(MaterialStack sta : stack) list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(sta.material.getUnlocalizedName()) + ": " + Mats.formatAmount(sta.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 16, 70, mouseX, mouseY, list);
|
||||
}
|
||||
|
||||
protected void drawStack(List<MaterialStack> stack, int capacity, int x, int y) {
|
||||
|
||||
if(stack.isEmpty()) return;
|
||||
|
||||
int lastHeight = 0;
|
||||
int lastQuant = 0;
|
||||
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
|
||||
for(MaterialStack sta : stack) {
|
||||
|
||||
int targetHeight = (lastQuant + sta.amount) * 70 / capacity;
|
||||
|
||||
if(lastHeight == targetHeight) continue; //skip draw calls that would be 0 pixels high
|
||||
|
||||
int hex = sta.material.moltenColor;
|
||||
//hex = 0xC18336;
|
||||
Color color = new Color(hex);
|
||||
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
|
||||
drawTexturedModalRect(guiLeft + x, guiTop + y - targetHeight, 208, 70 - targetHeight, 16, targetHeight - lastHeight);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.3F);
|
||||
drawTexturedModalRect(guiLeft + x, guiTop + y - targetHeight, 208, 70 - targetHeight, 16, targetHeight - lastHeight);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
lastQuant += sta.amount;
|
||||
lastHeight = targetHeight;
|
||||
}
|
||||
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glColor3f(255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +25,12 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
|
||||
recipes.put(new OreDictStack(KEY_SAND), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(1))));
|
||||
recipes.put(new OreDictStack(NETHERQUARTZ.gem()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 3)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(3))));
|
||||
recipes.put(new OreDictStack(NETHERQUARTZ.dust()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 3)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(3))));
|
||||
recipes.put(new OreDictStack(NETHERQUARTZ.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 12)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(12))));
|
||||
recipes.put(new OreDictStack(FIBER.ingot()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 4)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(1, 2))));
|
||||
recipes.put(new OreDictStack(FIBER.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 40)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(9, 2))));
|
||||
recipes.put(new OreDictStack(KEY_SAND), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(1))));
|
||||
recipes.put(new OreDictStack(QUARTZ.gem()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 3)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(3))));
|
||||
recipes.put(new OreDictStack(QUARTZ.dust()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 3)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(3))));
|
||||
recipes.put(new OreDictStack(QUARTZ.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 12)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.NUGGET.q(12))));
|
||||
recipes.put(new OreDictStack(FIBER.ingot()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 4)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(1, 2))));
|
||||
recipes.put(new OreDictStack(FIBER.block()), new ArcFurnaceRecipe().solid(new ItemStack(ModItems.nugget_silicon, 40)) .fluid(new MaterialStack(Mats.MAT_SILICON, MaterialShapes.INGOT.q(9, 2))));
|
||||
}
|
||||
|
||||
public static ArcFurnaceRecipe getOutput(ItemStack stack) {
|
||||
@ -43,7 +43,7 @@ public class ArcFurnaceRecipes extends SerializableRecipe {
|
||||
return recipes.get(comp);
|
||||
|
||||
for(Entry<AStack, ArcFurnaceRecipe> entry : recipes.entrySet()) {
|
||||
if(entry.getKey().isApplicable(stack)) return entry.getValue();
|
||||
if(entry.getKey().matchesRecipe(stack, true)) return entry.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -4,6 +4,7 @@ import com.hbm.items.ItemEnumMulti;
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemArcElectrode extends ItemEnumMulti {
|
||||
|
||||
@ -18,7 +19,18 @@ public class ItemArcElectrode extends ItemEnumMulti {
|
||||
return stack.stackTagCompound.getInteger("durability");
|
||||
}
|
||||
|
||||
public static int getMaxtDurability(ItemStack stack) {
|
||||
public static boolean damage(ItemStack stack) {
|
||||
if(!stack.hasTagCompound()) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
int durability = stack.stackTagCompound.getInteger("durability");
|
||||
durability++;
|
||||
stack.stackTagCompound.setInteger("durability", durability);
|
||||
return durability >= getMaxDurability(stack);
|
||||
}
|
||||
|
||||
public static int getMaxDurability(ItemStack stack) {
|
||||
EnumElectrodeType num = EnumUtil.grabEnumSafely(EnumElectrodeType.class, stack.getItemDamage());
|
||||
return num.durability;
|
||||
}
|
||||
@ -30,7 +42,7 @@ public class ItemArcElectrode extends ItemEnumMulti {
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return (double) getDurability(stack) / (double) getMaxtDurability(stack);
|
||||
return (double) getDurability(stack) / (double) getMaxDurability(stack);
|
||||
}
|
||||
|
||||
public static enum EnumElectrodeType {
|
||||
|
||||
@ -8,6 +8,7 @@ import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcFurnaceLarge;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -35,21 +36,78 @@ public class RenderArcFurnace extends TileEntitySpecialRenderer implements IItem
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.arc_furnace_tex);
|
||||
ResourceManager.arc_furnace.renderPart("Furnace");
|
||||
|
||||
if(!arc.liquids.isEmpty()) {
|
||||
fullbright(true);
|
||||
GL11.glTranslated(0, -1.75 + arc.getStackAmount(arc.liquids) * 1.75 / arc.maxLiquid, 0);
|
||||
ResourceManager.arc_furnace.renderPart("ContentsHot");
|
||||
fullbright(false);
|
||||
} else if(arc.hasMaterial) {
|
||||
ResourceManager.arc_furnace.renderPart("ContentsCold");
|
||||
}
|
||||
|
||||
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");
|
||||
ResourceManager.arc_furnace.renderPart("Ring1");
|
||||
ResourceManager.arc_furnace.renderPart("Ring2");
|
||||
ResourceManager.arc_furnace.renderPart("Ring3");
|
||||
ResourceManager.arc_furnace.renderPart("Electrode1");
|
||||
ResourceManager.arc_furnace.renderPart("Electrode2");
|
||||
ResourceManager.arc_furnace.renderPart("Electrode3");
|
||||
ResourceManager.arc_furnace.renderPart("Cable1");
|
||||
ResourceManager.arc_furnace.renderPart("Cable2");
|
||||
ResourceManager.arc_furnace.renderPart("Cable3");
|
||||
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");
|
||||
fullbright(true);
|
||||
if(arc.electrodes[0] == arc.ELECTRODE_USED) ResourceManager.arc_furnace.renderPart("Electrode1Hot");
|
||||
if(arc.electrodes[1] == arc.ELECTRODE_USED) ResourceManager.arc_furnace.renderPart("Electrode2Hot");
|
||||
if(arc.electrodes[2] == arc.ELECTRODE_USED) ResourceManager.arc_furnace.renderPart("Electrode3Hot");
|
||||
if(arc.electrodes[0] == arc.ELECTRODE_DEPLETED) ResourceManager.arc_furnace.renderPart("Electrode1Short");
|
||||
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();
|
||||
GL11.glTranslated(0, 5.5, 0.5);
|
||||
if(arc.isProgressing) GL11.glRotated(Math.sin((arc.getWorldObj().getTotalWorldTime() + interp) / 2) * 30, 1, 0, 0);
|
||||
GL11.glTranslated(0, -5.5, -0.5);
|
||||
ResourceManager.arc_furnace.renderPart("Cable1");
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(arc.electrodes[1] != arc.ELECTRODE_NONE) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 5.5, 0);
|
||||
if(arc.isProgressing) GL11.glRotated(Math.sin((arc.getWorldObj().getTotalWorldTime() + interp) / 2) * 30, 1, 0, 0);
|
||||
GL11.glTranslated(0, -5.5, 0);
|
||||
ResourceManager.arc_furnace.renderPart("Cable2");
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(arc.electrodes[2] != arc.ELECTRODE_NONE) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 5.5, -0.5);
|
||||
if(arc.isProgressing) GL11.glRotated(Math.sin((arc.getWorldObj().getTotalWorldTime() + interp) / 2) * 30, 1, 0, 0);
|
||||
GL11.glTranslated(0, -5.5, 0.5);
|
||||
ResourceManager.arc_furnace.renderPart("Cable3");
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void fullbright(boolean on) {
|
||||
|
||||
if(on) {
|
||||
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 {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemForRenderer() {
|
||||
|
||||
@ -3,18 +3,28 @@ package com.hbm.tileentity.machine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.interfaces.IControlReceiver;
|
||||
import com.hbm.inventory.UpgradeManager;
|
||||
import com.hbm.inventory.container.ContainerMachineArcFurnaceLarge;
|
||||
import com.hbm.inventory.gui.GUIMachineArcFurnaceLarge;
|
||||
import com.hbm.inventory.material.MaterialShapes;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.inventory.recipes.ArcFurnaceRecipes;
|
||||
import com.hbm.inventory.recipes.ArcFurnaceRecipes.ArcFurnaceRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemArcElectrode;
|
||||
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.TileEntityMachineBase;
|
||||
import com.hbm.util.CrucibleUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@ -22,22 +32,34 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider {
|
||||
public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider {
|
||||
|
||||
public long power;
|
||||
public static final long maxPower = 10_000_000;
|
||||
public boolean liquidMode = false;
|
||||
public float progress;
|
||||
public boolean isProgressing;
|
||||
public boolean hasMaterial;
|
||||
public int delay;
|
||||
|
||||
public float lid;
|
||||
public float prevLid;
|
||||
public int approachNum;
|
||||
public float syncLid;
|
||||
|
||||
public byte[] electrodes = new byte[3];
|
||||
public static final byte ELECTRODE_NONE = 0;
|
||||
public static final byte ELECTRODE_FRESH = 1;
|
||||
public static final byte ELECTRODE_USED = 2;
|
||||
public static final byte ELECTRODE_DEPLETED = 3;
|
||||
|
||||
public static final int maxLiquid = MaterialShapes.BLOCK.q(24);
|
||||
public List<MaterialStack> liquids = new ArrayList();
|
||||
|
||||
public TileEntityMachineArcFurnaceLarge() {
|
||||
@ -49,17 +71,13 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
return "container.machineArcFurnaceLarge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.power = Library.chargeTEFromItems(slots, 3, power, maxPower);
|
||||
this.isProgressing = false;
|
||||
|
||||
for(DirPos pos : getConPos()) this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
|
||||
@ -68,27 +86,61 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
boolean ingredients = this.hasIngredients();
|
||||
boolean electrodes = this.hasElectrodes();
|
||||
|
||||
if(ingredients && electrodes) {
|
||||
UpgradeManager.eval(slots, 4, 4);
|
||||
int upgrade = UpgradeManager.getLevel(UpgradeType.SPEED);
|
||||
|
||||
if(ingredients && electrodes && delay <= 0 && this.liquids.isEmpty()) {
|
||||
if(lid > 0) {
|
||||
lid -= 1F/60F;
|
||||
if(lid < 0) lid = 0;
|
||||
this.progress = 0;
|
||||
} else {
|
||||
this.progress += 1F/100F;
|
||||
int duration = 400 / (upgrade * 2 + 1);
|
||||
this.progress += 1F / duration;
|
||||
this.isProgressing = true;
|
||||
if(this.progress >= 1F) {
|
||||
this.process();
|
||||
this.progress = 0;
|
||||
this.delay = 120;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(this.delay > 0) delay--;
|
||||
this.progress = 0;
|
||||
if(lid < 1) {
|
||||
if(lid < 1 && this.electrodes[0] != 0 && this.electrodes[1] != 0 && this.electrodes[2] != 0) {
|
||||
lid += 1F/60F;
|
||||
if(lid > 1) lid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
hasMaterial = ingredients;
|
||||
}
|
||||
|
||||
this.decideElectrodeState();
|
||||
|
||||
if(!hasMaterial) hasMaterial = this.hasIngredients();
|
||||
|
||||
if(!this.liquids.isEmpty() && this.lid >= 1F) {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
||||
|
||||
Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
|
||||
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 2.875D, yCoord + 1.25D, zCoord + 0.5D + dir.offsetZ * 2.875D, 6, true, this.liquids, MaterialShapes.INGOT.q(1, 2), impact);
|
||||
|
||||
if(didPour != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "foundry");
|
||||
data.setInteger("color", didPour.material.moltenColor);
|
||||
data.setByte("dir", (byte) dir.ordinal());
|
||||
data.setFloat("off", 0.625F);
|
||||
data.setFloat("base", 0.625F);
|
||||
data.setFloat("len", Math.max(1F, yCoord + 1 - (float) (Math.ceil(impact.yCoord) - 0.875)));
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 2.875D, yCoord + 1, zCoord + 0.5D + dir.offsetZ * 2.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50));
|
||||
}
|
||||
}
|
||||
|
||||
this.liquids.removeIf(o -> o.amount <= 0);
|
||||
|
||||
this.networkPackNT(150);
|
||||
} else {
|
||||
|
||||
@ -103,15 +155,49 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
}
|
||||
}
|
||||
|
||||
public void decideElectrodeState() {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
|
||||
if(slots[i] != null) {
|
||||
if(slots[i].getItem() == ModItems.arc_electrode_burnt) { this.electrodes[i] = this.ELECTRODE_DEPLETED; continue; }
|
||||
if(slots[i].getItem() == ModItems.arc_electrode) {
|
||||
if(this.isProgressing || ItemArcElectrode.getDurability(slots[i]) > 0) this.electrodes[i] = this.ELECTRODE_USED;
|
||||
else this.electrodes[i] = this.ELECTRODE_FRESH;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
this.electrodes[i] = this.ELECTRODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public void process() {
|
||||
|
||||
for(int i = 5; i < 25; i++) {
|
||||
if(slots[i] == null) continue;
|
||||
ArcFurnaceRecipe recipe = ArcFurnaceRecipes.getOutput(slots[i]);
|
||||
if(recipe == null) continue;
|
||||
|
||||
if(!liquidMode && recipe.solidOutput != null) {
|
||||
slots[i] = recipe.solidOutput.copy();
|
||||
}
|
||||
|
||||
if(liquidMode && recipe.fluidOutput != null) {
|
||||
int liquid = this.getStackAmount(liquids);
|
||||
int toAdd = this.getStackAmount(recipe.fluidOutput);
|
||||
|
||||
if(liquid + toAdd <= this.maxLiquid) {
|
||||
slots[i] = null;
|
||||
for(MaterialStack stack : recipe.fluidOutput) {
|
||||
this.addToStack(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(ItemArcElectrode.damage(slots[i])) {
|
||||
slots[i] = new ItemStack(ModItems.arc_electrode_burnt, 1, slots[i].getItemDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,12 +221,58 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[] { 0, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
return this.isItemValidForSlot(slot, stack) && stack.stackSize <= 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if(slot < 3) return stack.getItem() == ModItems.arc_electrode;
|
||||
if(slot > 4) return lid > 0;
|
||||
if(slot > 4) {
|
||||
if(lid <= 0 || slots[slot] != null) return false;
|
||||
ArcFurnaceRecipe recipe = ArcFurnaceRecipes.getOutput(stack);
|
||||
if(recipe == null) return false;
|
||||
return liquidMode ? recipe.fluidOutput != null : recipe.solidOutput != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
if(slot < 3) return lid >= 1 && stack.getItem() != ModItems.arc_electrode;
|
||||
if(slot > 4) return lid > 0 && ArcFurnaceRecipes.getOutput(stack) == null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addToStack(MaterialStack matStack) {
|
||||
|
||||
for(MaterialStack mat : liquids) {
|
||||
if(mat.material == matStack.material) {
|
||||
mat.amount += matStack.amount;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
liquids.add(matStack.copy());
|
||||
}
|
||||
|
||||
public static int getStackAmount(List<MaterialStack> stack) {
|
||||
int amount = 0;
|
||||
for(MaterialStack mat : stack) amount += mat.amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static int getStackAmount(MaterialStack[] stack) {
|
||||
int amount = 0;
|
||||
for(MaterialStack mat : stack) amount += mat.amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
protected DirPos[] getConPos() {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
|
||||
@ -162,6 +294,18 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
buf.writeLong(power);
|
||||
buf.writeFloat(progress);
|
||||
buf.writeFloat(lid);
|
||||
buf.writeBoolean(isProgressing);
|
||||
buf.writeBoolean(liquidMode);
|
||||
buf.writeBoolean(hasMaterial);
|
||||
|
||||
for(int i = 0; i < 3; i++) buf.writeByte(electrodes[i]);
|
||||
|
||||
buf.writeShort(liquids.size());
|
||||
|
||||
for(MaterialStack mat : liquids) {
|
||||
buf.writeInt(mat.material.id);
|
||||
buf.writeInt(mat.amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -170,6 +314,18 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
this.power = buf.readLong();
|
||||
this.progress = buf.readFloat();
|
||||
this.syncLid = buf.readFloat();
|
||||
this.isProgressing = buf.readBoolean();
|
||||
this.liquidMode = buf.readBoolean();
|
||||
this.hasMaterial = buf.readBoolean();
|
||||
|
||||
for(int i = 0; i < 3; i++) electrodes[i] = buf.readByte();
|
||||
|
||||
int mats = buf.readShort();
|
||||
|
||||
this.liquids.clear();
|
||||
for(int i = 0; i < mats; i++) {
|
||||
liquids.add(new MaterialStack(Mats.matById.get(buf.readInt()), buf.readInt()));
|
||||
}
|
||||
|
||||
this.approachNum = 2;
|
||||
}
|
||||
@ -224,4 +380,17 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIMachineArcFurnaceLarge(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return this.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
if(data.getBoolean("liquid")) {
|
||||
this.liquidMode = !this.liquidMode;
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 28 KiB |
Loading…
x
Reference in New Issue
Block a user