caster is finished, woo!

This commit is contained in:
70000hp 2023-12-31 15:56:09 -05:00
parent b6f1d422e8
commit 9340287403
8 changed files with 760 additions and 921 deletions

View File

@ -32,16 +32,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay { public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay, IToolable {
public MachineStrandCaster() { public MachineStrandCaster() {
super(Material.iron); super(Material.iron);
} }
//reminder, if the machine is a solid brick, get dimensions will already handle it without the need to use fillSapce //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 //the order is up, down, forward, backward, left, right
//x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know //x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know
@Override @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 @Override
public int getOffset() { public int getOffset() {
@ -51,8 +54,8 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineStrandCaster(); if (meta >= 12) return new TileEntityMachineStrandCaster();
if(meta >= 6) return new TileEntityProxyCombo(true, false, true).moltenMetal(); if (meta >= 6) return new TileEntityProxyCombo(true, false, true).moltenMetal();
return null; 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) { 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); 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); 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]); 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; TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
return caster.canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack); 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) { 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); 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); 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]); 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; TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
return caster.pour(world, x, y, z, dX, dY, dZ, side, stack); return caster.pour(world, x, y, z, dX, dY, dZ, side, stack);
@ -121,13 +124,13 @@ public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcce
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { 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; return true;
} }
int[] coords = findCore(world, x, y, z); int[] coords = findCore(world, x, y, z);
TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) world.getTileEntity(coords[0], coords[1], coords[2]); TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) world.getTileEntity(coords[0], coords[1], coords[2]);
if(cast != null) { if (cast != null) {
//insert mold //insert mold
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.mold && cast.slots[0] == null) { if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.mold && cast.slots[0] == null) {
cast.slots[0] = player.getHeldItem().copy(); 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) { public void breakBlock(World world, int x, int y, int z, Block b, int i) {
TileEntity te = world.getTileEntity(x, y, z); TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityMachineStrandCaster) { if (te instanceof TileEntityMachineStrandCaster) {
TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) te; TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) te;
if (cast.amount > 0) { 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) { public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
int[] coords = findCore(world, x, y, 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]); TileEntityMachineStrandCaster cast = (TileEntityMachineStrandCaster) world.getTileEntity(coords[0], coords[1], coords[2]);
List<String> text = new ArrayList(); List<String> text = new ArrayList();
if(cast != null) { if (cast != null) {
if (cast.slots[0] == null) { if (cast.slots[0] == null) {
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast")); text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast"));
} else if (cast.slots[0].getItem() == ModItems.mold) { } 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); ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xFF4000, 0x401000, text);
} }
@Override @Override
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) { protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
x += dir.offsetX * o; x += dir.offsetX * o;
z += dir.offsetZ * 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); 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;
}
} }

View File

@ -11,65 +11,65 @@ import net.minecraft.item.ItemStack;
public class ContainerMachineStrandCaster extends Container { public class ContainerMachineStrandCaster extends Container {
protected TileEntityMachineStrandCaster caster; protected TileEntityMachineStrandCaster caster;
public ContainerMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster caster) { public ContainerMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster caster) {
this.caster = 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));
}
}
//the wretched mold
for(int i = 0; i < 3; i++) { this.addSlotToContainer(new SlotNonRetarded(this.caster, 0, 57, 62));
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++) { //output
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190)); 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()) { for (int i = 0; i < 3; i++) {
ItemStack originalStack = slot.getStack(); for (int j = 0; j < 9; j++) {
stack = originalStack.copy(); this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 132 + i * 18));
}
}
if(index <= 6) { for (int i = 0; i < 9; i++) {
if(!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 7, this.inventorySlots.size(), true)) { this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190));
return null; }
} }
slot.onSlotChange(originalStack, stack);
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 0, 7, false)) {
return null;
}
if(originalStack.stackSize == 0) { @Override
slot.putStack(null); public ItemStack transferStackInSlot(EntityPlayer player, int index) {
} else { ItemStack stack = null;
slot.onSlotChanged(); Slot slot = (Slot) this.inventorySlots.get(index);
}
}
return stack; if (slot != null && slot.getHasStack()) {
} ItemStack originalStack = slot.getStack();
stack = originalStack.copy();
@Override if (index <= 6) {
public boolean canInteractWith(EntityPlayer player) { if (!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 7, this.inventorySlots.size(), true)) {
return caster.isUseableByPlayer(player); 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);
}
} }

View File

@ -21,80 +21,78 @@ import java.util.List;
public class GUIMachineStrandCaster extends GuiInfoContainer { public class GUIMachineStrandCaster extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_strand_caster.png"); private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_strand_caster.png");
private TileEntityMachineStrandCaster caster; private TileEntityMachineStrandCaster caster;
public GUIMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster tedf) { public GUIMachineStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster tedf) {
super(new ContainerMachineStrandCaster(invPlayer, tedf)); super(new ContainerMachineStrandCaster(invPlayer, tedf));
caster = tedf; caster = tedf;
this.xSize = 176; this.xSize = 176;
this.ySize = 214; this.ySize = 214;
} }
@Override @Override
public void drawScreen(int x, int y, float interp) { public void drawScreen(int x, int y, float interp) {
super.drawScreen(x, y, 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.water.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 14, 16, 24);
caster.steam.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 64, 16, 24); caster.steam.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 64, 16, 24);
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(int i, int j) { protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.caster.hasCustomInventoryName() ? this.caster.getInventoryName() : I18n.format(this.caster.getInventoryName()); 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(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(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { 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); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture); Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); 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; int hex = caster.type.moltenColor;
//hex = 0xC18336; //hex = 0xC18336;
Color color = new Color(hex); Color color = new Color(hex);
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight); drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 0.3F); GL11.glColor4f(1F, 1F, 1F, 0.3F);
drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight); drawTexturedModalRect(guiLeft + 17, guiTop + 93 - targetHeight, 176, 89 - targetHeight, 34, targetHeight);
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
} }
OpenGlHelper.glBlendFunc(770, 771, 1, 0); OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor3f(255, 255, 255); GL11.glColor3f(255, 255, 255);
caster.water.renderTank(guiLeft + 82, guiTop + 38, 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); caster.steam.renderTank(guiLeft + 82, guiTop + 90, this.zLevel, 16, 24);
} }
protected void drawStackInfo(int mouseX, int mouseY, int x, int y) {
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)));
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);
}
} }

View File

@ -445,6 +445,15 @@ public class AssemblerRecipes {
new ComparableStack(ModItems.wire_red_copper, 24), new ComparableStack(ModItems.wire_red_copper, 24),
new ComparableStack(ModItems.circuit_copper, 1) new ComparableStack(ModItems.circuit_copper, 1)
}, 300); }, 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[] { makeRecipe(new ComparableStack(ModItems.piston_set, 1, EnumPistonType.STEEL.ordinal()), new AStack[] {
new OreDictStack(STEEL.plate(), 16), new OreDictStack(STEEL.plate(), 16),
new OreDictStack(CU.plate(), 4), new OreDictStack(CU.plate(), 4),

View File

@ -2,18 +2,34 @@ package com.hbm.render.tileentity;
import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase; 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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.nio.DoubleBuffer;
public class RenderStrandCaster extends TileEntitySpecialRenderer implements IItemRendererProvider { 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 @Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float interp) { 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.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5); 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); GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.strand_caster_tex); 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.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix(); GL11.glPopMatrix();
@ -48,11 +110,11 @@ public class RenderStrandCaster extends TileEntitySpecialRenderer implements IIt
public IItemRenderer getRenderer() { public IItemRenderer getRenderer() {
return new ItemRenderBase( ) { return new ItemRenderBase( ) {
public void renderInventory() { public void renderInventory() {
GL11.glTranslated(1, 1, 0); GL11.glTranslated(2, 0, 2);
GL11.glScaled(2.5, 2.5, 2.5); GL11.glScaled( 2, 2, 2);
} }
public void renderCommon() { public void renderCommon() {
GL11.glScaled(0.5, 0.5, 0.5); GL11.glScaled(1, 1, 1);
GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.strand_caster_tex); ResourceManager.strand_caster.renderAll(); bindTexture(ResourceManager.strand_caster_tex); ResourceManager.strand_caster.renderAll();
GL11.glShadeModel(GL11.GL_FLAT); GL11.glShadeModel(GL11.GL_FLAT);

View File

@ -158,7 +158,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); 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) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
@ -198,7 +198,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
} }
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); 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) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();

View File

@ -32,14 +32,16 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
//god thank you bob for this base class //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 water;
public FluidTank steam; public FluidTank steam;
@Override @Override
public String getName() { public String getName() {
return "container.machineStrandCaster"; return "container.machineStrandCaster";
} }
@Override @Override
public String getInventoryName() { public String getInventoryName() {
return getName(); return getName();
@ -64,12 +66,12 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
} }
if (this.amount >= this.getCapacity()) { if (this.amount >= this.getCapacity()) {
if(amount > getCapacity()) { if (amount > getCapacity()) {
ItemStack scrap = ItemScraps.create(new Mats.MaterialStack(type, amount)); ItemStack scrap = ItemScraps.create(new Mats.MaterialStack(type, amount));
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, scrap); EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, scrap);
worldObj.spawnEntityInWorld(item); worldObj.spawnEntityInWorld(item);
} }
this.amount = this.getCapacity(); this.amount = this.getCapacity();
} }
@ -83,61 +85,61 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
if (canProcess()) { 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++) { for (int j = 0; j < itemsCasted; j++) {
this.amount -= mold.getCost(); this.amount -= mold.getCost();
ItemStack out = mold.getOutput(type); 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;
}
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() { public boolean canProcess() {
ItemMold.Mold mold = this.getInstalledMold(); 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++) { 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())
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 water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();;
} }
} }
return false; return false;
} }
public DirPos[] getFluidConPos() { public DirPos[] getFluidConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); 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 * 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 - 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), 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 dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); 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 + rot.offsetX - dir.offsetX, yCoord + 2, zCoord + rot.offsetZ - dir.offsetZ},
new int[]{xCoord - dir.offsetX, yCoord + 2, zCoord - 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 + rot.offsetX, yCoord + 2, zCoord + rot.offsetZ},
new int[]{xCoord, yCoord + 2, zCoord}, new int[]{xCoord, yCoord + 2, zCoord},
}; };
} }
@Override @Override
public ItemMold.Mold getInstalledMold() { 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 ((ItemMold) slots[0].getItem()).getMold(slots[0]);
} }
return null; return null;
} }
@Override @Override
public int getMoldSize() { public int getMoldSize() {
return getInstalledMold().size; return getInstalledMold().size;
@ -175,9 +179,9 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
@Override @Override
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) { 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()) { 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); return this.standardCheck(world, x, y, z, side, stack);
} }
} }
@ -187,40 +191,42 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
@Override @Override
public boolean standardCheck(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) { 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); return !(this.amount >= this.getCapacity() || getInstalledMold() == null);
} }
@Override @Override
public int getCapacity() { public int getCapacity() {
ItemMold.Mold mold = this.getInstalledMold(); ItemMold.Mold mold = this.getInstalledMold();
return mold == null ? 50000 : mold.getCost() * 50; return mold == null ? 50000 : mold.getCost() * 10;
} }
private int getWaterRequired() { private int getWaterRequired() {
return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 50; return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 50;
} }
private void updateConnections() { private void updateConnections() {
for(DirPos pos : getFluidConPos()) { for (DirPos pos : getFluidConPos()) {
this.trySubscribe(water.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); 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()); sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
} }
} }
@Override @Override
public FluidTank[] getSendingTanks() { public FluidTank[] getSendingTanks() {
return new FluidTank[] { steam }; return new FluidTank[]{steam};
} }
@Override @Override
public FluidTank[] getReceivingTanks() { public FluidTank[] getReceivingTanks() {
return new FluidTank[] { water }; return new FluidTank[]{water};
} }
@Override @Override
public FluidTank[] getAllTanks() { public FluidTank[] getAllTanks() {
return new FluidTank[] { water, steam }; return new FluidTank[]{water, steam};
} }
@Override @Override
@ -235,16 +241,17 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
} }
public void networkPack(NBTTagCompound nbt, int range) { 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)); PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
} }
@Override @Override
public void networkUnpack(NBTTagCompound nbt) { public void networkUnpack(NBTTagCompound nbt) {
water.readFromNBT(nbt, "w"); water.readFromNBT(nbt, "w");
steam.readFromNBT(nbt, "s"); steam.readFromNBT(nbt, "s");
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
@ -258,10 +265,11 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
water.readFromNBT(nbt, "w"); water.readFromNBT(nbt, "w");
steam.readFromNBT(nbt, "s"); steam.readFromNBT(nbt, "s");
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack) { public boolean isItemValidForSlot(int i, ItemStack stack) {
if(i == 0) { if (i == 0) {
return stack.getItem() == ModItems.mold; return stack.getItem() == ModItems.mold;
} }
@ -276,15 +284,16 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
@Override @Override
public int[] getAccessibleSlotsFromSide(int meta) { 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() { public void markChanged() {
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
} }
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player) { public boolean isUseableByPlayer(EntityPlayer player) {
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {
return false; return false;
} else { } else {
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 128; 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) { public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return !this.isItemValidForSlot(slot, itemStack); return !this.isItemValidForSlot(slot, itemStack);
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if (bb == null) {
bb = AxisAlignedBB.getBoundingBox( bb = AxisAlignedBB.getBoundingBox(
xCoord - 1, xCoord - 1,
yCoord, yCoord,
zCoord - 1, zCoord - 1,
xCoord + 2, xCoord + 6,
yCoord + 3, yCoord + 3,
zCoord + 7 zCoord + 6
); );
} }
return bb; return bb;
} }
} }

File diff suppressed because it is too large Load Diff