crucible GUI, smeltable material definitions
@ -4,6 +4,7 @@ import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.tileentity.machine.TileEntityCrucible;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@ -21,6 +22,11 @@ public class MachineCrucible extends BlockDummyable {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityCrucible;
|
||||
|
||||
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 ContainerCrucible extends Container {
|
||||
|
||||
protected TileEntityCrucible crucible;
|
||||
|
||||
public ContainerCrucible(InventoryPlayer invPlayer, TileEntityCrucible crucible) {
|
||||
this.crucible = crucible;
|
||||
|
||||
//input
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(crucible, j + i * 3, 107 + j * 18, 18 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
//template
|
||||
this.addSlotToContainer(new Slot(crucible, 9, 107, 81));
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 132 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack originalStack = slot.getStack();
|
||||
stack = originalStack.copy();
|
||||
|
||||
if(index <= 9) {
|
||||
if(!this.mergeItemStack(originalStack, 10, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(originalStack, stack);
|
||||
|
||||
} else if(!this.mergeItemStack(originalStack, 0, 10, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(originalStack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return crucible.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
46
src/main/java/com/hbm/inventory/gui/GUICrucible.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerCrucible;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityCrucible;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUICrucible extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_crucible.png");
|
||||
private TileEntityCrucible crucible;
|
||||
|
||||
public GUICrucible(InventoryPlayer invPlayer, TileEntityCrucible tedf) {
|
||||
super(new ContainerCrucible(invPlayer, tedf));
|
||||
crucible = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 214;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.crucible.hasCustomInventoryName() ? this.crucible.getInventoryName() : I18n.format(this.crucible.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 0xffffff);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,17 @@
|
||||
package com.hbm.inventory.material;
|
||||
|
||||
/* with every new rewrite, optimization and improvement, the code becomes more gregian */
|
||||
public class Mats {
|
||||
|
||||
public static NTMMaterial
|
||||
|
||||
IRON = make("Iron"),
|
||||
GOLD = make("Gold"),
|
||||
STEEL = make("Steel"),
|
||||
TUNGSTEN = make("Tungsten"),
|
||||
COPPER = make("Copper");
|
||||
|
||||
public static NTMMaterial make(String... names) {
|
||||
return new NTMMaterial(names);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,24 +10,41 @@ public class NTMMaterial {
|
||||
public String[] names;
|
||||
public MaterialShapes[] shapes = new MaterialShapes[0];
|
||||
public boolean omitItemGen = false;
|
||||
public boolean smeltable = false;
|
||||
public SmeltingBehavior smeltable = SmeltingBehavior.NOT_SMELTABLE;
|
||||
public int moltenColor = 0xFF4A00;
|
||||
|
||||
public NTMMaterial(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
/** Shapes for autogen */
|
||||
public NTMMaterial setShapes(MaterialShapes... shapes) {
|
||||
this.shapes = shapes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NTMMaterial omit() {
|
||||
/** Turn off autogen for this material, use this for vanilla stuff */
|
||||
public NTMMaterial omitAutoGen() {
|
||||
this.omitItemGen = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NTMMaterial smeltable() {
|
||||
this.smeltable = true;
|
||||
/** Defines smelting behavior */
|
||||
public NTMMaterial smeltable(SmeltingBehavior behavior) {
|
||||
this.smeltable = behavior;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NTMMaterial setMoltenColor(int color) {
|
||||
this.moltenColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static enum SmeltingBehavior {
|
||||
NOT_SMELTABLE, //anything that can't be smelted or otherwise doesn't belong in a smelter, like diamond
|
||||
VAPORIZES, //can't be smelted because the material would skadoodle
|
||||
BREAKS, //can't be smelted because the material doesn't survive the temperatures
|
||||
SMELTABLE, //metal, mostly
|
||||
ADDITIVE //stuff like coal which isn't smeltable but can be put in a crucible anyway
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,27 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import com.hbm.inventory.container.ContainerCrucible;
|
||||
import com.hbm.inventory.gui.GUICrucible;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
|
||||
public class TileEntityCrucible extends TileEntityMachineBase {
|
||||
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.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityCrucible extends TileEntityMachineBase implements IGUIProvider {
|
||||
|
||||
public TileEntityCrucible() {
|
||||
super(1);
|
||||
super(10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
return "container.machineCrucible";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -18,4 +29,39 @@ public class TileEntityCrucible extends TileEntityMachineBase {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerCrucible(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUICrucible(player.inventory, this);
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
||||
if(bb == null) {
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 1,
|
||||
yCoord,
|
||||
zCoord - 1,
|
||||
xCoord + 2,
|
||||
yCoord + 2,
|
||||
zCoord + 2
|
||||
);
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 713 B |
|
Before Width: | Height: | Size: 944 B After Width: | Height: | Size: 944 B |
|
After Width: | Height: | Size: 233 B |