mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
ICF pellet press
This commit is contained in:
parent
fca9fe50da
commit
ffd0b19620
@ -1,6 +1,8 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotTakeOnly;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityICFPress;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -42,10 +44,49 @@ public class ContainerICFPress extends Container {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 155));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int id) {
|
||||
return null;
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= 7) {
|
||||
if(!this.mergeItemStack(var5, 8, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
|
||||
if(var3.getItem() == ModItems.icf_pellet_empty) {
|
||||
if(!this.mergeItemStack(var5, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if(var3.getItem() instanceof IItemFluidIdentifier) {
|
||||
if(!this.mergeItemStack(var5, 6, 8, false)) {
|
||||
return null;
|
||||
}
|
||||
} else if(var3.getItem() == ModItems.particle_muon) {
|
||||
if(!this.mergeItemStack(var5, 2, 3, false)) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if(!this.mergeItemStack(var5, 4, 6, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerICFPress;
|
||||
@ -9,16 +11,17 @@ import com.hbm.tileentity.machine.TileEntityICFPress;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIICFPress extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_icf_press.png");
|
||||
private TileEntityICFPress diesel;
|
||||
private TileEntityICFPress press;
|
||||
|
||||
public GUIICFPress(InventoryPlayer invPlayer, TileEntityICFPress tedf) {
|
||||
super(new ContainerICFPress(invPlayer, tedf));
|
||||
diesel = tedf;
|
||||
press = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 179;
|
||||
@ -27,11 +30,17 @@ public class GUIICFPress extends GuiInfoContainer {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
press.tanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 44, guiTop + 18, 16, 52);
|
||||
press.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 52);
|
||||
|
||||
if(this.isMouseOverSlot(this.inventorySlots.getSlot(4), mouseX, mouseY)) this.func_146283_a(Arrays.asList(new String[] {EnumChatFormatting.YELLOW + "Item input: Top/Bottom"}), mouseX, mouseY);
|
||||
if(this.isMouseOverSlot(this.inventorySlots.getSlot(5), mouseX, mouseY)) this.func_146283_a(Arrays.asList(new String[] {EnumChatFormatting.YELLOW + "Item input: Sides"}), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.diesel.hasCustomInventoryName() ? this.diesel.getInventoryName() : I18n.format(this.diesel.getInventoryName());
|
||||
String name = this.press.hasCustomInventoryName() ? this.press.getInventoryName() : I18n.format(this.press.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
@ -42,5 +51,11 @@ public class GUIICFPress extends GuiInfoContainer {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int m = press.muon * 52 / press.maxMuon;
|
||||
drawTexturedModalRect(guiLeft + 28, guiTop + 70 - m, 176, 52 - m, 4, m);
|
||||
|
||||
press.tanks[0].renderTank(guiLeft + 44, guiTop + 70, this.zLevel, 16, 52);
|
||||
press.tanks[1].renderTank(guiLeft + 152, guiTop + 70, this.zLevel, 16, 52);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +110,8 @@ public class Mats {
|
||||
public static final NTMMaterial MAT_COBALT = makeSmeltable(2700, CO, 0xC2D1EE, 0x353554, 0x8F72AE).setShapes(NUGGET, DUSTTINY, BILLET, INGOT, DUST, BLOCK);
|
||||
public static final NTMMaterial MAT_BORON = makeSmeltable(500, B, 0xBDC8D2, 0x29343E, 0xAD72AE).setShapes(DUSTTINY, INGOT, DUST, BLOCK);
|
||||
public static final NTMMaterial MAT_ZIRCONIUM = makeSmeltable(4000, ZR, 0xE3DCBE, 0x3E3719, 0xADA688).setShapes(NUGGET, DUSTTINY, BILLET, INGOT, DUST, CASTPLATE, WELDEDPLATE, BLOCK);
|
||||
public static final NTMMaterial MAT_SODIUM = makeSmeltable(1100, NA, 0xD3BF9E, 0x3A5A6B, 0x7E9493).setShapes(DUST);
|
||||
public static final NTMMaterial MAT_CALCIUM = makeSmeltable(2000, CA, 0xCFCFA6, 0x747F6E, 0xB7B784).setShapes(INGOT, DUST);
|
||||
public static final NTMMaterial MAT_LITHIUM = makeSmeltable(300, LI, 0xFFFFFF, 0x818181, 0xD6D6D6).setShapes(INGOT, DUST, BLOCK);
|
||||
public static final NTMMaterial MAT_CADMIUM = makeSmeltable(4800, CD, 0xFFFADE, 0x350000, 0xA85600).setShapes(INGOT, DUST);
|
||||
public static final NTMMaterial MAT_OSMIRIDIUM = makeSmeltable(7699, OSMIRIDIUM, 0xDBE3EF, 0x7891BE, 0xACBDD9).setShapes(NUGGET, INGOT, CASTPLATE, WELDEDPLATE);
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
package com.hbm.items.machine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.NTMMaterial;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
@ -34,7 +39,7 @@ public class ItemICFPellet extends Item {
|
||||
LITHIUM( 0xE9E9E9, 1.0D, 1.0D, 1.0D), //fuck off
|
||||
BERYLLIUM( 0xA79D80, 1.0D, 1.0D, 1.0D),
|
||||
BORON( 0x697F89, 1.0D, 1.0D, 1.0D),
|
||||
CARBON( 0x454545, 1.0D, 1.0D, 1.0D),
|
||||
//CARBON( 0x454545, 1.0D, 1.0D, 1.0D),
|
||||
OXYGEN( 0xB4E2FF, 1.0D, 1.0D, 1.0D),
|
||||
SODIUM( 0xDFE4E7, 1.0D, 1.0D, 1.0D),
|
||||
//aluminium, silicon, phosphorus
|
||||
@ -55,6 +60,24 @@ public class ItemICFPellet extends Item {
|
||||
this.fusingDifficulty = laser;
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<FluidType, EnumICFFuel> fluidMap = new HashMap();
|
||||
public static HashMap<NTMMaterial, EnumICFFuel> materialMap = new HashMap();
|
||||
|
||||
public static void init() {
|
||||
if(!fluidMap.isEmpty() && !materialMap.isEmpty()) return;
|
||||
fluidMap.put(Fluids.HYDROGEN, EnumICFFuel.HYDROGEN);
|
||||
fluidMap.put(Fluids.DEUTERIUM, EnumICFFuel.DEUTERIUM);
|
||||
fluidMap.put(Fluids.TRITIUM, EnumICFFuel.TRITIUM);
|
||||
fluidMap.put(Fluids.HELIUM3, EnumICFFuel.HELIUM3);
|
||||
fluidMap.put(Fluids.HELIUM4, EnumICFFuel.HELIUM4);
|
||||
materialMap.put(Mats.MAT_LITHIUM, EnumICFFuel.LITHIUM);
|
||||
materialMap.put(Mats.MAT_BERYLLIUM, EnumICFFuel.BERYLLIUM);
|
||||
materialMap.put(Mats.MAT_BORON, EnumICFFuel.BORON);
|
||||
materialMap.put(Mats.MAT_SODIUM, EnumICFFuel.SODIUM);
|
||||
fluidMap.put(Fluids.CHLORINE, EnumICFFuel.CHLORINE);
|
||||
materialMap.put(Mats.MAT_CALCIUM, EnumICFFuel.CALCIUM);
|
||||
}
|
||||
|
||||
public ItemICFPellet() {
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
@ -1,21 +1,31 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.inventory.container.ContainerICFPress;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIICFPress;
|
||||
import com.hbm.inventory.material.MaterialShapes;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemICFPellet;
|
||||
import com.hbm.items.machine.ItemICFPellet.EnumICFFuel;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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.world.World;
|
||||
|
||||
public class TileEntityICFPress extends TileEntityMachineBase implements IGUIProvider {
|
||||
public class TileEntityICFPress extends TileEntityMachineBase implements IFluidStandardReceiver, IGUIProvider {
|
||||
|
||||
public FluidTank[] tanks;
|
||||
public int muon;
|
||||
@ -37,10 +47,80 @@ public class TileEntityICFPress extends TileEntityMachineBase implements IGUIPro
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.tanks[0].setType(6, slots);
|
||||
this.tanks[1].setType(7, slots);
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.subscribeToAllAround(tanks[0].getTankType(), this);
|
||||
this.subscribeToAllAround(tanks[1].getTankType(), this);
|
||||
}
|
||||
|
||||
if(muon <= 0 && slots[2] != null && slots[2].getItem() == ModItems.particle_muon) {
|
||||
|
||||
ItemStack container = slots[2].getItem().getContainerItem(slots[2]);
|
||||
boolean canStore = false;
|
||||
|
||||
if(container == null) {
|
||||
canStore = true;
|
||||
} else if(slots[3] == null) {
|
||||
slots[3] = container.copy();
|
||||
canStore = true;
|
||||
} else if(slots[3].getItem() == container.getItem() && slots[3].getItemDamage() == container.getItemDamage() && slots[3].stackSize < slots[3].getMaxStackSize()) {
|
||||
slots[3].stackSize++;
|
||||
canStore = true;
|
||||
}
|
||||
|
||||
if(canStore) {
|
||||
this.muon = this.maxMuon;
|
||||
this.decrStackSize(2, 1);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
press();
|
||||
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
public void press() {
|
||||
if(slots[0] == null || slots[0].getItem() != ModItems.icf_pellet_empty) return;
|
||||
if(slots[1] != null) return;
|
||||
|
||||
ItemICFPellet.init();
|
||||
|
||||
EnumICFFuel fuel1 = getFuel(tanks[0], slots[4], 0);
|
||||
EnumICFFuel fuel2 = getFuel(tanks[1], slots[5], 0);
|
||||
|
||||
if(fuel1 == null || fuel2 == null || fuel1 == fuel2) return;
|
||||
|
||||
slots[1] = ItemICFPellet.setup(fuel1, fuel2, muon > 0);
|
||||
|
||||
if(muon > 0) muon--;
|
||||
|
||||
this.decrStackSize(0, 1);
|
||||
if(usedFluid[0]) tanks[0].setFill(tanks[0].getFill() - 1000); else this.decrStackSize(4, 1);
|
||||
if(usedFluid[1]) tanks[1].setFill(tanks[1].getFill() - 1000); else this.decrStackSize(5, 1);
|
||||
|
||||
this.markChanged();
|
||||
}
|
||||
|
||||
public static boolean[] usedFluid = new boolean[2];
|
||||
|
||||
public EnumICFFuel getFuel(FluidTank tank, ItemStack slot, int index) {
|
||||
usedFluid[index] = false;
|
||||
if(tank.getFill() >= 1000 && ItemICFPellet.fluidMap.containsKey(tank.getTankType())) {
|
||||
usedFluid[index] = true;
|
||||
return ItemICFPellet.fluidMap.get(tank.getTankType());
|
||||
}
|
||||
if(slot == null) return null;
|
||||
List<MaterialStack> mats = Mats.getMaterialsFromItem(slot);
|
||||
if(mats == null || mats.size() != 1) return null;
|
||||
MaterialStack mat = mats.get(0);
|
||||
if(mat.amount != MaterialShapes.INGOT.q(1)) return null;
|
||||
return ItemICFPellet.materialMap.get(mat.material);
|
||||
}
|
||||
|
||||
@Override public void serialize(ByteBuf buf) {
|
||||
super.serialize(buf);
|
||||
@ -58,6 +138,21 @@ public class TileEntityICFPress extends TileEntityMachineBase implements IGUIPro
|
||||
tanks[1].deserialize(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if(stack.getItem() == ModItems.icf_pellet_empty) return slot == 0;
|
||||
if(stack.getItem() == ModItems.particle_muon) return slot == 2;
|
||||
return slot == 4 || slot == 5;
|
||||
}
|
||||
|
||||
public static final int[] topBottom = new int[] {0, 1, 2, 3, 4};
|
||||
public static final int[] sides = new int[] {0, 1, 2, 3, 5};
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return side == 0 || side == 1 ? topBottom : sides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerICFPress(player.inventory, this);
|
||||
@ -68,4 +163,14 @@ public class TileEntityICFPress extends TileEntityMachineBase implements IGUIPro
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIICFPress(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return tanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return tanks;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user