diff --git a/src/main/java/api/hbm/block/ICrucibleAcceptor.java b/src/main/java/api/hbm/block/ICrucibleAcceptor.java index b94433534..2ecfcd1ee 100644 --- a/src/main/java/api/hbm/block/ICrucibleAcceptor.java +++ b/src/main/java/api/hbm/block/ICrucibleAcceptor.java @@ -59,11 +59,12 @@ public interface ICrucibleAcceptor { for(MaterialStack stack : stacks) { - if(stack.material.smeltable != SmeltingBehavior.SMELTABLE) + if(stack.material.smeltable != SmeltingBehavior.SMELTABLE) { continue; + } - if(acc.canAcceptPartialPour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit).getOpposite(), stack)) { - MaterialStack left = acc.pour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit).getOpposite(), stack); + if(acc.canAcceptPartialPour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit), stack)) { + MaterialStack left = acc.pour(world, mop.blockX, mop.blockY, mop.blockZ, hit.xCoord, hit.yCoord, hit.zCoord, ForgeDirection.getOrientation(mop.sideHit), stack); if(left == null) { left = new MaterialStack(stack.material, 0); } diff --git a/src/main/java/com/hbm/blocks/machine/FoundryCastingBase.java b/src/main/java/com/hbm/blocks/machine/FoundryCastingBase.java index 486ddd7f2..7b968c4aa 100644 --- a/src/main/java/com/hbm/blocks/machine/FoundryCastingBase.java +++ b/src/main/java/com/hbm/blocks/machine/FoundryCastingBase.java @@ -85,6 +85,7 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc cast.slots[1] = null; cast.markDirty(); + world.markBlockForUpdate(x, y, z); return true; } @@ -96,8 +97,9 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc cast.slots[0] = player.getHeldItem().copy(); cast.slots[0].stackSize = 1; player.getHeldItem().stackSize--; - cast.markDirty(); world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F); + cast.markDirty(); + world.markBlockForUpdate(x, y, z); return true; } } @@ -123,6 +125,9 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc player.inventoryContainer.detectAndSendChanges(); } + cast.markDirty(); + world.markBlockForUpdate(x, y, z); + cast.slots[0] = null; cast.markDirty(); @@ -135,7 +140,7 @@ public abstract class FoundryCastingBase extends BlockContainer implements ICruc List text = new ArrayList(); if(cast.slots[0] == null) { - text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noMold")); + text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast")); } else if(cast.slots[0].getItem() == ModItems.mold){ Mold mold = ((ItemMold) cast.slots[0].getItem()).getMold(cast.slots[0]); text.add(EnumChatFormatting.BLUE + I18nUtil.resolveKey("shape." + mold.shape.name().toLowerCase()) + " x" + mold.amount); diff --git a/src/main/java/com/hbm/render/tileentity/RenderFoundry.java b/src/main/java/com/hbm/render/tileentity/RenderFoundry.java index b6fbf9f85..4bc23824e 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderFoundry.java +++ b/src/main/java/com/hbm/render/tileentity/RenderFoundry.java @@ -7,69 +7,129 @@ import org.lwjgl.opengl.GL11; import com.hbm.lib.RefStrings; import com.hbm.tileentity.machine.IRenderFoundry; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; public class RenderFoundry extends TileEntitySpecialRenderer { public static final ResourceLocation lava = new ResourceLocation(RefStrings.MODID, "textures/models/machines/lava_gray.png"); + + private void drawItem(ItemStack stack, double height) { + GL11.glPushMatrix(); + RenderItem render = new RenderItem(); + GL11.glTranslated(0.125D, height, 0.125D); + + double scale = 0.0625D * 12D / 16D; + GL11.glScaled(scale, scale, scale); + + GL11.glRotated(90, 1, 0, 0); + RenderHelper.enableGUIStandardItemLighting(); + if(!ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), Minecraft.getMinecraft().getTextureManager(), stack, true, 0.0F, 1.0F, 0.0F)) { + render.renderItemIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), stack, 0, 0); + } + GL11.glPopMatrix(); + RenderHelper.enableStandardItemLighting(); + } + + private void drawBlock(ItemStack stack, IRenderFoundry foundry) { + Tessellator tess = Tessellator.instance; + Block b = ((ItemBlock)stack.getItem()).field_150939_a; + IIcon icon = b.getIcon(1, stack.getItemDamage()); + bindTexture(TextureMap.locationBlocksTexture); + + tess.startDrawingQuads(); + tess.setNormal(0F, 1F, 0F); + tess.setColorRGBA_F(1F, 1F, 1F, 0.3F); + double h = foundry.outHeight(); + tess.addVertexWithUV(foundry.minX(), h, foundry.minZ(), icon.getMinU(), icon.getMaxV()); + tess.addVertexWithUV(foundry.minX(), h, foundry.maxZ(), icon.getMaxU(), icon.getMaxV()); + tess.addVertexWithUV(foundry.maxX(), h, foundry.maxZ(), icon.getMaxU(), icon.getMinV()); + tess.addVertexWithUV(foundry.maxX(), h, foundry.minZ(), icon.getMinU(), icon.getMinV()); + tess.draw(); + } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) { IRenderFoundry foundry = (IRenderFoundry) tile; - - if(!foundry.shouldRender()) return; + Tessellator tess = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslated(x, y, z); - GL11.glDepthMask(false); - Tessellator tess = Tessellator.instance; - this.bindTexture(lava); - - int hex = foundry.getMat().moltenColor; - Color color = new Color(hex); - - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_CULL_FACE); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F); - - tess.startDrawingQuads(); - tess.setNormal(0F, 1F, 0F); - tess.setColorRGBA_F(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F); - tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX()); - tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX()); - tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX()); - tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX()); - tess.draw(); - - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - tess.startDrawingQuads(); - tess.setNormal(0F, 1F, 0F); - tess.setColorRGBA_F(1F, 1F, 1F, 0.3F); - tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX()); - tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX()); - tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX()); - tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX()); - tess.draw(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - - GL11.glDepthMask(true); - if(foundry instanceof IInventory) { IInventory inv = (IInventory) foundry; + ItemStack mold = inv.getStackInSlot(0); + + if(mold != null) { + drawItem(mold, foundry.moldHeight()); + } + ItemStack out = inv.getStackInSlot(1); + + if(out != null) { + if(out.getItem() instanceof ItemBlock) { + drawBlock(out, foundry); + } else { + drawItem(out, foundry.outHeight()); + } + } + } + + if(foundry.shouldRender()) { + + GL11.glDepthMask(false); + this.bindTexture(lava); + + int hex = foundry.getMat().moltenColor; + Color color = new Color(hex); + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F); + + tess.startDrawingQuads(); + tess.setNormal(0F, 1F, 0F); + tess.setColorRGBA_F(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F); + tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX()); + tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX()); + tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX()); + tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX()); + tess.draw(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + tess.startDrawingQuads(); + tess.setNormal(0F, 1F, 0F); + tess.setColorRGBA_F(1F, 1F, 1F, 0.3F); + tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.maxX()); + tess.addVertexWithUV(foundry.minX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.maxX()); + tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.maxZ(), foundry.maxZ(), foundry.minX()); + tess.addVertexWithUV(foundry.maxX(), foundry.getLevel(), foundry.minZ(), foundry.minZ(), foundry.minX()); + tess.draw(); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + + GL11.glDepthMask(true); } GL11.glPopMatrix(); diff --git a/src/main/java/com/hbm/tileentity/machine/IRenderFoundry.java b/src/main/java/com/hbm/tileentity/machine/IRenderFoundry.java index 057a05c42..cae2f1e93 100644 --- a/src/main/java/com/hbm/tileentity/machine/IRenderFoundry.java +++ b/src/main/java/com/hbm/tileentity/machine/IRenderFoundry.java @@ -16,4 +16,6 @@ public interface IRenderFoundry { public double maxX(); public double minZ(); public double maxZ(); + public double moldHeight(); + public double outHeight(); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java index ddf46931b..0f31dd73c 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java @@ -98,7 +98,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); Vec3 impact = Vec3.createVectorHelper(0, 0, 0); - ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.75D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.75D, 6, true, this.wasteStack, MaterialShapes.NUGGET.q(1), impact); + ICrucibleAcceptor.tryPour(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(1), impact); } if(!this.recipeStack.isEmpty()) { @@ -123,7 +123,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro } Vec3 impact = Vec3.createVectorHelper(0, 0, 0); - ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.75D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.75D, 6, true, toCast, MaterialShapes.NUGGET.q(1), impact); + ICrucibleAcceptor.tryPour(worldObj, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord + 0.25D, zCoord + 0.5D + dir.offsetZ * 1.875D, 6, true, toCast, MaterialShapes.NUGGET.q(1), impact); } this.recipeStack.removeIf(o -> o.amount <= 0); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBasin.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBasin.java index 1d2a7a390..145c2159a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBasin.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryBasin.java @@ -41,4 +41,6 @@ public class TileEntityFoundryBasin extends TileEntityFoundryCastingBase impleme @Override public double maxX() { return 0.875D; } @Override public double minZ() { return 0.125D; } @Override public double maxZ() { return 0.875D; } + @Override public double moldHeight() { return 0.13D; } + @Override public double outHeight() { return 0.875D; } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java index 0ddadd2c5..02c558698 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryCastingBase.java @@ -31,6 +31,15 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase super.updateEntity(); if(!worldObj.isRemote) { + + if(this.amount > this.getCapacity()) { + this.amount = this.getCapacity(); + } + + if(this.amount == 0) { + this.type = null; + } + Mold mold = this.getInstalledMold(); if(mold != null && this.amount == this.getCapacity() && slots[1] == null) { @@ -123,10 +132,12 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } @Override public ItemStack decrStackSize(int slot, int amount) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); if(slots[slot] != null) { if(slots[slot].stackSize <= amount) { ItemStack itemStack = slots[slot]; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryMold.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryMold.java index 43c33ffce..607b1d13c 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryMold.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryMold.java @@ -33,4 +33,6 @@ public class TileEntityFoundryMold extends TileEntityFoundryCastingBase implemen @Override public double maxX() { return 0.875D; } @Override public double minZ() { return 0.125D; } @Override public double maxZ() { return 0.875D; } + @Override public double moldHeight() { return 0.13D; } + @Override public double outHeight() { return 0.25D; } }