mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
caster is finished, woo!
This commit is contained in:
parent
b6f1d422e8
commit
9340287403
@ -32,16 +32,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay {
|
||||
public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay, IToolable {
|
||||
|
||||
public MachineStrandCaster() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
//reminder, if the machine is a solid brick, get dimensions will already handle it without the need to use fillSapce
|
||||
//the order is up, down, forward, backward, left, right
|
||||
//x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know
|
||||
@Override
|
||||
public int[] getDimensions() {return new int[]{0, 0, 6, 0, 1, 0};}
|
||||
public int[] getDimensions() {
|
||||
return new int[]{0, 0, 6, 0, 1, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
@ -51,8 +54,8 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
|
||||
if(meta >= 12) return new TileEntityMachineStrandCaster();
|
||||
if(meta >= 6) return new TileEntityProxyCombo(true, false, true).moltenMetal();
|
||||
if (meta >= 12) return new TileEntityMachineStrandCaster();
|
||||
if (meta >= 6) return new TileEntityProxyCombo(true, false, true).moltenMetal();
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -83,12 +86,12 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
|
||||
TileEntity poured = world.getTileEntity(x, y, z);
|
||||
if(!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo)poured).moltenMetal)) return false;
|
||||
if (!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo) poured).moltenMetal)) return false;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
if(pos == null) return false;
|
||||
if (pos == null) return false;
|
||||
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(!(tile instanceof TileEntityMachineStrandCaster)) return false;
|
||||
if (!(tile instanceof TileEntityMachineStrandCaster)) return false;
|
||||
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
|
||||
|
||||
return caster.canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack);
|
||||
@ -98,12 +101,12 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
public Mats.MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
|
||||
TileEntity poured = world.getTileEntity(x, y, z);
|
||||
if(!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo)poured).moltenMetal)) return stack;
|
||||
if (!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo) poured).moltenMetal)) return stack;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
if(pos == null) return stack;
|
||||
if (pos == null) return stack;
|
||||
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(!(tile instanceof TileEntityMachineStrandCaster)) return stack;
|
||||
if (!(tile instanceof TileEntityMachineStrandCaster)) return stack;
|
||||
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
|
||||
|
||||
return caster.pour(world, x, y, z, dX, dY, dZ, side, stack);
|
||||
@ -121,13 +124,13 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote) {
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int[] coords = findCore(world, x, y, z);
|
||||
TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) world.getTileEntity(coords[0], coords[1], coords[2]);
|
||||
if(cast != null) {
|
||||
if (cast != null) {
|
||||
//insert mold
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.mold && cast.slots[0] == null) {
|
||||
cast.slots[0] = player.getHeldItem().copy();
|
||||
@ -164,7 +167,7 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int i) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileEntityMachineStrandCaster) {
|
||||
if (te instanceof TileEntityMachineStrandCaster) {
|
||||
TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) te;
|
||||
|
||||
if (cast.amount > 0) {
|
||||
@ -179,12 +182,12 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
|
||||
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
|
||||
int[] coords = findCore(world, x, y, z);
|
||||
if(coords == null) return;
|
||||
if (coords == null) return;
|
||||
|
||||
TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) world.getTileEntity(coords[0], coords[1], coords[2]);
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
if(cast != null) {
|
||||
if (cast != null) {
|
||||
if (cast.slots[0] == null) {
|
||||
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast"));
|
||||
} else if (cast.slots[0].getItem() == ModItems.mold) {
|
||||
@ -194,13 +197,40 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
|
||||
}
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xFF4000, 0x401000, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
|
||||
x += dir.offsetX * o;
|
||||
z += dir.offsetZ * o;
|
||||
|
||||
if(!MultiblockHandlerXR.checkSpace(world, x, y , z, getDimensions(), x, y, z, dir)) return false;
|
||||
if (!MultiblockHandlerXR.checkSpace(world, x, y, z, getDimensions(), x, y, z, dir)) return false;
|
||||
return MultiblockHandlerXR.checkSpace(world, x, y, z, new int[]{2, 0, 1, 0, 1, 0}, x, y, z, dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
if (tool != ToolType.SCREWDRIVER)
|
||||
return false;
|
||||
|
||||
TileEntityFoundryCastingBase cast = (TileEntityFoundryCastingBase) world.getTileEntity(x, y, z);
|
||||
|
||||
if (cast.slots[0] == null)
|
||||
return false;
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(cast.slots[0].copy())) {
|
||||
EntityItem item = new EntityItem(world, x + 0.5, y + this.maxY, z + 0.5, cast.slots[0].copy());
|
||||
world.spawnEntityInWorld(item);
|
||||
} else {
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
cast.slots[0] = null;
|
||||
cast.markDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,65 +11,65 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachineStrandCaster extends Container {
|
||||
|
||||
protected TileEntityMachineStrandCaster caster;
|
||||
protected TileEntityMachineStrandCaster caster;
|
||||
|
||||
public ContainerMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster caster) {
|
||||
this.caster = caster;
|
||||
|
||||
//the wretched mold
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, 0, 57, 62));
|
||||
|
||||
//output
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 2; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, j + i * 2 + 1, 125 + j * 18, 26 + i * 18));
|
||||
}
|
||||
}
|
||||
public ContainerMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster caster) {
|
||||
this.caster = caster;
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
//the wretched mold
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, 0, 57, 62));
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190));
|
||||
}
|
||||
}
|
||||
//output
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, j + i * 2 + 1, 125 + j * 18, 26 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
if(index <= 6) {
|
||||
if(!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 7, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(originalStack, stack);
|
||||
|
||||
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 0, 7, false)) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190));
|
||||
}
|
||||
}
|
||||
|
||||
if(originalStack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
return stack;
|
||||
}
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack originalStack = slot.getStack();
|
||||
stack = originalStack.copy();
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return caster.isUseableByPlayer(player);
|
||||
}
|
||||
if (index <= 6) {
|
||||
if (!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 7, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(originalStack, stack);
|
||||
|
||||
} else if (!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 0, 7, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (originalStack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return caster.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,80 +21,78 @@ import java.util.List;
|
||||
|
||||
public class GUIMachineStrandCaster extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_strand_caster.png");
|
||||
private TileEntityMachineStrandCaster caster;
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_strand_caster.png");
|
||||
private TileEntityMachineStrandCaster caster;
|
||||
|
||||
public GUIMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster tedf) {
|
||||
super(new ContainerMachineStrandCaster(invPlayer, tedf));
|
||||
caster = tedf;
|
||||
public GUIMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster tedf) {
|
||||
super(new ContainerMachineStrandCaster(invPlayer, tedf));
|
||||
caster = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 214;
|
||||
}
|
||||
this.xSize = 176;
|
||||
this.ySize = 214;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
drawStackInfo(x, y, 16, 17);
|
||||
drawStackInfo(x, y, 16, 17);
|
||||
|
||||
caster.water.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 14, 16, 24);
|
||||
caster.steam.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 64, 16, 24);
|
||||
}
|
||||
caster.water.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 14, 16, 24);
|
||||
caster.steam.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 64, 16, 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.caster.hasCustomInventoryName() ? this.caster.getInventoryName() : I18n.format(this.caster.getInventoryName());
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.caster.hasCustomInventoryName() ? this.caster.getInventoryName() : I18n.format(this.caster.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 4, 0xffffff);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 4, 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_) {
|
||||
@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);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if (caster.amount != 0) {
|
||||
if (caster.amount != 0) {
|
||||
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
|
||||
int targetHeight = (caster.amount) * 79 / caster.getCapacity();
|
||||
int targetHeight = Math.min((caster.amount) * 79 / caster.getCapacity(), 92);
|
||||
|
||||
int hex = caster.type.moltenColor;
|
||||
//hex = 0xC18336;
|
||||
Color color = new Color(hex);
|
||||
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.3F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
int hex = caster.type.moltenColor;
|
||||
//hex = 0xC18336;
|
||||
Color color = new Color(hex);
|
||||
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.3F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
}
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glColor3f(255, 255, 255);
|
||||
}
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glColor3f(255, 255, 255);
|
||||
|
||||
caster.water.renderTank(guiLeft + 82, guiTop + 38, this.zLevel, 16, 24);
|
||||
caster.steam.renderTank(guiLeft + 82, guiTop + 90, this.zLevel, 16, 24);
|
||||
caster.water.renderTank(guiLeft + 82, guiTop + 38, this.zLevel, 16, 24);
|
||||
caster.steam.renderTank(guiLeft + 82, guiTop + 90, this.zLevel, 16, 24);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void drawStackInfo(int mouseX, int mouseY, int x, int y) {
|
||||
|
||||
List<String> list = new ArrayList();
|
||||
|
||||
if(caster.type == null) list.add(EnumChatFormatting.RED + "Empty");
|
||||
else list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(caster.type.getUnlocalizedName()) + ": " + Mats.formatAmount(caster.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||
protected void drawStackInfo(int mouseX, int mouseY, int x, int y) {
|
||||
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list);
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList();
|
||||
|
||||
if (caster.type == null) list.add(EnumChatFormatting.RED + "Empty");
|
||||
else
|
||||
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(caster.type.getUnlocalizedName()) + ": " + Mats.formatAmount(caster.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -445,6 +445,15 @@ public class AssemblerRecipes {
|
||||
new ComparableStack(ModItems.wire_red_copper, 24),
|
||||
new ComparableStack(ModItems.circuit_copper, 1)
|
||||
}, 300);
|
||||
|
||||
makeRecipe(new ComparableStack(ModBlocks.machine_strand_caster, 1), new AStack[] {
|
||||
new ComparableStack(ModItems.ingot_firebrick, 12),
|
||||
new OreDictStack(STEEL.plateCast(), 6),
|
||||
new OreDictStack(CU.plateWelded(), 2),
|
||||
new ComparableStack(ModItems.tank_steel, 2),
|
||||
new OreDictStack(ANY_CONCRETE.any(), 8)
|
||||
}, 100);
|
||||
|
||||
makeRecipe(new ComparableStack(ModItems.piston_set, 1, EnumPistonType.STEEL.ordinal()), new AStack[] {
|
||||
new OreDictStack(STEEL.plate(), 16),
|
||||
new OreDictStack(CU.plate(), 4),
|
||||
|
||||
@ -2,18 +2,34 @@ package com.hbm.render.tileentity;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.render.item.ItemRenderBase;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineStrandCaster;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.nio.DoubleBuffer;
|
||||
|
||||
public class RenderStrandCaster extends TileEntitySpecialRenderer implements IItemRendererProvider {
|
||||
public static final ResourceLocation lava = new ResourceLocation(RefStrings.MODID, "textures/models/machines/lava_gray.png");
|
||||
private static DoubleBuffer buf = null;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) {
|
||||
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) te;
|
||||
|
||||
if(buf == null){
|
||||
buf = GLAllocation.createDirectByteBuffer(8*4).asDoubleBuffer();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
@ -31,8 +47,54 @@ public class RenderStrandCaster extends TileEntitySpecialRenderer implements IIt
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
bindTexture(ResourceManager.strand_caster_tex);
|
||||
ResourceManager.strand_caster.renderAll();
|
||||
|
||||
ResourceManager.strand_caster.renderPart("caster");
|
||||
|
||||
|
||||
if (caster.amount != 0 && caster.getInstalledMold() != null) {
|
||||
|
||||
double level = ((double) caster.amount / (double) caster.getCapacity()) * 0.675D;
|
||||
double offset = ((double) caster.amount / (double) caster.getInstalledMold().getCost()) * 0.375D;
|
||||
|
||||
int color = caster.type.moltenColor;
|
||||
|
||||
int r = color >> 16 & 0xFF;
|
||||
int g = color >> 8 & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f( r/ 255F, g/ 255F, b/ 255F);
|
||||
GL11.glEnable(GL11.GL_CLIP_PLANE0);
|
||||
buf.put(new double[] { 0, 0, -1, 0.5} );
|
||||
buf.rewind();
|
||||
GL11.glClipPlane(GL11.GL_CLIP_PLANE0, buf);
|
||||
GL11.glTranslated(0,0,-offset + 3.4);
|
||||
ResourceManager.strand_caster.renderPart("plate");
|
||||
GL11.glDisable(GL11.GL_CLIP_PLANE0);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F);
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.setNormal(0F, 1F, 0F);
|
||||
tess.setColorOpaque_F(r / 255F, g / 255F, b / 255F);
|
||||
bindTexture(lava);
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(-0.9, 2.3 + level, -0.999, 0, 0);
|
||||
tess.addVertexWithUV(-0.9, 2.3 + level, 0.999, 0, 1);
|
||||
tess.addVertexWithUV(0.9, 2.3 + level, 0.999, 1, 1);
|
||||
tess.addVertexWithUV(0.9, 2.3 + level, -0.999, 1, 0);
|
||||
tess.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
@ -48,11 +110,11 @@ public class RenderStrandCaster extends TileEntitySpecialRenderer implements IIt
|
||||
public IItemRenderer getRenderer() {
|
||||
return new ItemRenderBase( ) {
|
||||
public void renderInventory() {
|
||||
GL11.glTranslated(1, 1, 0);
|
||||
GL11.glScaled(2.5, 2.5, 2.5);
|
||||
GL11.glTranslated(2, 0, 2);
|
||||
GL11.glScaled( 2, 2, 2);
|
||||
}
|
||||
public void renderCommon() {
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
GL11.glScaled(1, 1, 1);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
bindTexture(ResourceManager.strand_caster_tex); ResourceManager.strand_caster.renderAll();
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
@ -158,7 +158,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
|
||||
Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
|
||||
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(2), impact);
|
||||
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(3), impact);
|
||||
|
||||
if(didPour != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
@ -198,7 +198,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
|
||||
}
|
||||
|
||||
Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
|
||||
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(2), impact);
|
||||
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3), impact);
|
||||
|
||||
if(didPour != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
@ -32,14 +32,16 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
//god thank you bob for this base class
|
||||
public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase implements IGUIProvider, ICrucibleAcceptor,ISidedInventory, IFluidStandardTransceiver, INBTPacketReceiver, IInventory {
|
||||
public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase implements IGUIProvider, ICrucibleAcceptor, ISidedInventory, IFluidStandardTransceiver, INBTPacketReceiver, IInventory {
|
||||
|
||||
public FluidTank water;
|
||||
public FluidTank steam;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "container.machineStrandCaster";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getName();
|
||||
@ -64,12 +66,12 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
}
|
||||
|
||||
if (this.amount >= this.getCapacity()) {
|
||||
if(amount > getCapacity()) {
|
||||
if (amount > getCapacity()) {
|
||||
ItemStack scrap = ItemScraps.create(new Mats.MaterialStack(type, amount));
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, scrap);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
this.amount = this.getCapacity();
|
||||
this.amount = this.getCapacity();
|
||||
|
||||
}
|
||||
|
||||
@ -83,61 +85,61 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
|
||||
if (canProcess()) {
|
||||
|
||||
int itemsCasted = Math.min(amount / mold.getCost(), 9);
|
||||
int itemsCasted = Math.min(amount / mold.getCost(), 9);
|
||||
|
||||
for (int j = 0; j < itemsCasted; j++) {
|
||||
this.amount -= mold.getCost();
|
||||
for (int j = 0; j < itemsCasted; j++) {
|
||||
this.amount -= mold.getCost();
|
||||
|
||||
ItemStack out = mold.getOutput(type);
|
||||
|
||||
for (int i = 1; i < 7; i++) {
|
||||
if (slots[i] == null){
|
||||
slots[i] = out.copy();
|
||||
break;
|
||||
}
|
||||
|
||||
if (slots[i].isItemEqual(out) && slots[i].stackSize + out.stackSize <= out.getMaxStackSize()) {
|
||||
slots[i].stackSize += out.stackSize;
|
||||
break;
|
||||
}
|
||||
ItemStack out = mold.getOutput(type);
|
||||
|
||||
for (int i = 1; i < 7; i++) {
|
||||
if (slots[i] == null) {
|
||||
slots[i] = out.copy();
|
||||
break;
|
||||
}
|
||||
|
||||
if (slots[i].isItemEqual(out) && slots[i].stackSize + out.stackSize <= out.getMaxStackSize()) {
|
||||
slots[i].stackSize += out.stackSize;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
markChanged();
|
||||
|
||||
water.setFill(water.getFill() - getWaterRequired() * itemsCasted);
|
||||
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted);
|
||||
}
|
||||
markChanged();
|
||||
|
||||
water.setFill(water.getFill() - getWaterRequired() * itemsCasted);
|
||||
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted);
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
water.writeToNBT(data, "w");
|
||||
steam.writeToNBT(data, "s");
|
||||
|
||||
this.networkPack(data, 150);
|
||||
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
water.writeToNBT(data, "w");
|
||||
steam.writeToNBT(data, "s");
|
||||
|
||||
this.networkPack(data, 150);
|
||||
|
||||
}
|
||||
|
||||
public boolean canProcess() {
|
||||
ItemMold.Mold mold = this.getInstalledMold();
|
||||
if(type != null && mold != null && this.amount >= mold.getCost() * 9 && mold.getOutput(type) != null) {
|
||||
if (type != null && mold != null && this.amount >= mold.getCost() * 9 && mold.getOutput(type) != null) {
|
||||
for (int i = 1; i < 7; i++) {
|
||||
|
||||
if (slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize())
|
||||
return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();;
|
||||
if (slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize())
|
||||
return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public DirPos[] getFluidConPos() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
return new DirPos[] {
|
||||
return new DirPos[]{
|
||||
new DirPos(xCoord + rot.offsetX * 2 - dir.offsetX, yCoord, zCoord + rot.offsetZ * 2 - dir.offsetZ, rot),
|
||||
new DirPos(xCoord - rot.offsetX - dir.offsetX, yCoord, zCoord - rot.offsetZ - dir.offsetZ, rot.getOpposite()),
|
||||
new DirPos(xCoord + rot.offsetX * 2 - dir.offsetX * 5, yCoord, zCoord + rot.offsetZ * 2 - dir.offsetZ * 5, rot),
|
||||
@ -150,23 +152,25 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
return new int[][] {
|
||||
return new int[][]{
|
||||
new int[]{xCoord + rot.offsetX - dir.offsetX, yCoord + 2, zCoord + rot.offsetZ - dir.offsetZ},
|
||||
new int[]{xCoord - dir.offsetX, yCoord + 2, zCoord - dir.offsetZ},
|
||||
new int[]{xCoord + rot.offsetX, yCoord + 2, zCoord + rot.offsetZ},
|
||||
new int[]{xCoord, yCoord + 2, zCoord},
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemMold.Mold getInstalledMold() {
|
||||
if(slots[0] == null) return null;
|
||||
if (slots[0] == null) return null;
|
||||
|
||||
if(slots[0].getItem() == ModItems.mold) {
|
||||
if (slots[0].getItem() == ModItems.mold) {
|
||||
return ((ItemMold) slots[0].getItem()).getMold(slots[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMoldSize() {
|
||||
return getInstalledMold().size;
|
||||
@ -175,9 +179,9 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
@Override
|
||||
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
|
||||
if(side != ForgeDirection.UP) return false;
|
||||
if (side != ForgeDirection.UP) return false;
|
||||
for (int[] pos : getMetalPourPos()) {
|
||||
if (pos[0]== x && pos[1] == y && pos[2] == z){
|
||||
if (pos[0] == x && pos[1] == y && pos[2] == z) {
|
||||
return this.standardCheck(world, x, y, z, side, stack);
|
||||
}
|
||||
}
|
||||
@ -187,40 +191,42 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
|
||||
@Override
|
||||
public boolean standardCheck(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
if(this.type != null && this.type != stack.material) return false;
|
||||
if (this.type != null && this.type != stack.material) return false;
|
||||
return !(this.amount >= this.getCapacity() || getInstalledMold() == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
ItemMold.Mold mold = this.getInstalledMold();
|
||||
return mold == null ? 50000 : mold.getCost() * 50;
|
||||
return mold == null ? 50000 : mold.getCost() * 10;
|
||||
}
|
||||
|
||||
private int getWaterRequired() {
|
||||
return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 50;
|
||||
}
|
||||
|
||||
private void updateConnections() {
|
||||
for(DirPos pos : getFluidConPos()) {
|
||||
for (DirPos pos : getFluidConPos()) {
|
||||
this.trySubscribe(water.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
for(DirPos pos : getFluidConPos()) {
|
||||
for (DirPos pos : getFluidConPos()) {
|
||||
sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] { steam };
|
||||
return new FluidTank[]{steam};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] { water };
|
||||
return new FluidTank[]{water};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return new FluidTank[] { water, steam };
|
||||
return new FluidTank[]{water, steam};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -235,16 +241,17 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
}
|
||||
|
||||
public void networkPack(NBTTagCompound nbt, int range) {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
if (!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
water.readFromNBT(nbt, "w");
|
||||
steam.readFromNBT(nbt, "s");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
@ -258,10 +265,11 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
water.readFromNBT(nbt, "w");
|
||||
steam.readFromNBT(nbt, "s");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
|
||||
if(i == 0) {
|
||||
if (i == 0) {
|
||||
return stack.getItem() == ModItems.mold;
|
||||
}
|
||||
|
||||
@ -276,15 +284,16 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int meta) {
|
||||
return new int[] { 1, 2, 3, 4, 5, 6};
|
||||
return new int[]{1, 2, 3, 4, 5, 6};
|
||||
}
|
||||
|
||||
public void markChanged() {
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
|
||||
if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
|
||||
return false;
|
||||
} else {
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 128;
|
||||
@ -301,25 +310,24 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
||||
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
||||
return !this.isItemValidForSlot(slot, itemStack);
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
||||
if(bb == null) {
|
||||
if (bb == null) {
|
||||
bb = AxisAlignedBB.getBoundingBox(
|
||||
xCoord - 1,
|
||||
yCoord,
|
||||
zCoord - 1,
|
||||
xCoord + 2,
|
||||
xCoord + 6,
|
||||
yCoord + 3,
|
||||
zCoord + 7
|
||||
zCoord + 6
|
||||
);
|
||||
}
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user