From 22e96fefd483a1711a90f0a3abd61a80d4f1a105 Mon Sep 17 00:00:00 2001 From: Bob Date: Mon, 20 Mar 2023 21:12:52 +0100 Subject: [PATCH] inventory proxy for blast furnace extension, cast metal sploosh particle --- .../java/com/hbm/blocks/IProxyController.java | 15 ++ .../hbm/blocks/machine/BlockHadronAccess.java | 28 ++- .../machine/MachineDiFurnaceExtension.java | 18 +- src/main/java/com/hbm/main/ClientProxy.java | 11 ++ .../com/hbm/particle/ParticleFoundry.java | 181 ++++++++++++++++++ .../com/hbm/particle/ParticleRBMKMush.java | 18 +- .../hbm/tileentity/TileEntityProxyBase.java | 29 +-- .../hbm/tileentity/TileEntityProxyCombo.java | 2 +- .../machine/TileEntityCrucible.java | 31 ++- .../machine/TileEntityFoundryOutlet.java | 24 ++- src/main/java/com/hbm/util/Compat.java | 2 - 11 files changed, 313 insertions(+), 46 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/IProxyController.java create mode 100644 src/main/java/com/hbm/particle/ParticleFoundry.java diff --git a/src/main/java/com/hbm/blocks/IProxyController.java b/src/main/java/com/hbm/blocks/IProxyController.java new file mode 100644 index 000000000..984876590 --- /dev/null +++ b/src/main/java/com/hbm/blocks/IProxyController.java @@ -0,0 +1,15 @@ +package com.hbm.blocks; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +/** + * Custom handling that tells TileEntityProxyBase where the core for a given proxy block is. + * BlockDummyable doesn't implement this since it already has its own standardized core finding code. + * + * @author hbm + */ +public interface IProxyController { + + public TileEntity getCore(World world, int x, int y, int z); +} diff --git a/src/main/java/com/hbm/blocks/machine/BlockHadronAccess.java b/src/main/java/com/hbm/blocks/machine/BlockHadronAccess.java index 9b8667f15..e42c47beb 100644 --- a/src/main/java/com/hbm/blocks/machine/BlockHadronAccess.java +++ b/src/main/java/com/hbm/blocks/machine/BlockHadronAccess.java @@ -1,9 +1,12 @@ package com.hbm.blocks.machine; +import com.hbm.blocks.IProxyController; import com.hbm.blocks.ModBlocks; import com.hbm.handler.BossSpawnHandler; import com.hbm.main.MainRegistry; import com.hbm.tileentity.TileEntityProxyInventory; +import com.hbm.tileentity.machine.TileEntityHadron; +import com.hbm.util.Compat; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; @@ -19,7 +22,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class BlockHadronAccess extends BlockContainer { +public class BlockHadronAccess extends BlockContainer implements IProxyController { public BlockHadronAccess(Material mat) { super(mat); @@ -59,19 +62,11 @@ public class BlockHadronAccess extends BlockContainer { ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); - /*for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - System.out.println(d.name() + " " + d.getOpposite().name()); - } - - System.out.println(dir.name());*/ - for(int i = 1; i < 3; i++) { if(world.getBlock(x + dir.offsetX * i, y + dir.offsetY * i, z + dir.offsetZ * i) == ModBlocks.hadron_core) { FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x + dir.offsetX * i, y + dir.offsetY * i, z + dir.offsetZ * i); } - - //System.out.println(world.getBlock(x + dir.offsetX * i, y + dir.offsetY * i, z + dir.offsetZ * i).getUnlocalizedName()); } return true; @@ -80,4 +75,19 @@ public class BlockHadronAccess extends BlockContainer { return false; } } + + @Override + public TileEntity getCore(World world, int x, int y, int z) { + ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)); + + for(int i = 1; i < 3; i++) { + TileEntity te = Compat.getTileStandard(world, x + dir.offsetX * i, y + dir.offsetY * i, z + dir.offsetZ * i); + + if(te instanceof TileEntityHadron) { + return te; + } + } + + return null; + } } diff --git a/src/main/java/com/hbm/blocks/machine/MachineDiFurnaceExtension.java b/src/main/java/com/hbm/blocks/machine/MachineDiFurnaceExtension.java index 85d5509a3..3b8c4208f 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineDiFurnaceExtension.java +++ b/src/main/java/com/hbm/blocks/machine/MachineDiFurnaceExtension.java @@ -1,14 +1,17 @@ package com.hbm.blocks.machine; +import com.hbm.blocks.IProxyController; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; +import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityDiFurnace; +import com.hbm.util.Compat; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -16,7 +19,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class MachineDiFurnaceExtension extends Block { +public class MachineDiFurnaceExtension extends BlockContainer implements IProxyController { @SideOnly(Side.CLIENT) private IIcon iconTop; @SideOnly(Side.CLIENT) private IIcon iconBottom; @@ -24,6 +27,11 @@ public class MachineDiFurnaceExtension extends Block { public MachineDiFurnaceExtension() { super(Material.rock); } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityProxyCombo().inventory(); + } @Override @SideOnly(Side.CLIENT) @@ -66,4 +74,10 @@ public class MachineDiFurnaceExtension extends Block { public boolean renderAsNormalBlock() { return false; } + + @Override + public TileEntity getCore(World world, int x, int y, int z) { + TileEntity tile = Compat.getTileStandard(world, x, y - 1, z); + return tile instanceof TileEntityDiFurnace ? tile : null; + } } diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 72d8cae68..86c24758f 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -1798,6 +1798,17 @@ public class ClientProxy extends ServerProxy { ejector.spawnCasing(man, casingConfig, world, x, y, z, data.getFloat("pitch"), data.getFloat("yaw"), data.getBoolean("crouched")); } } + + if("foundry".equals(type)) { + int color = data.getInteger("color"); + byte dir = data.getByte("dir"); + float length = data.getFloat("len"); + float base = data.getFloat("base"); + float offset = data.getFloat("off"); + + ParticleFoundry sploosh = new ParticleFoundry(man, world, x, y, z, color, dir, length, base, offset); + Minecraft.getMinecraft().effectRenderer.addEffect(sploosh); + } } private HashMap vanished = new HashMap(); diff --git a/src/main/java/com/hbm/particle/ParticleFoundry.java b/src/main/java/com/hbm/particle/ParticleFoundry.java new file mode 100644 index 000000000..ff224f350 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleFoundry.java @@ -0,0 +1,181 @@ +package com.hbm.particle; + +import java.awt.Color; + +import org.lwjgl.opengl.GL11; + +import com.hbm.lib.RefStrings; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +@SideOnly(Side.CLIENT) +public class ParticleFoundry extends EntityFX { + + protected int color; + protected ForgeDirection dir; + /* how far the metal splooshes down from the base point */ + protected double length; + /* the material coming right out of the faucet, either above or next to the base point */ + protected double base; + /* how far the base part goes back */ + protected double offset; + + public static final ResourceLocation lava = new ResourceLocation(RefStrings.MODID + ":textures/blocks/lava_gray.png"); + private TextureManager theRenderEngine; + + public ParticleFoundry(TextureManager texan, World world, double x, double y, double z, int color, int direction, double length, double base, double offset) { + super(world, x, y, z); + this.color = color; + this.dir = ForgeDirection.getOrientation(direction); + this.theRenderEngine = texan; //it's a little texan man we enslaved to do the texture binding for us + this.length = length; + this.base = base; + this.offset = offset; + + this.particleMaxAge = 20; + } + + @Override + public void onUpdate() { + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if(this.particleAge++ >= this.particleMaxAge) { + this.setDead(); + } + } + + @Override + public int getFXLayer() { + return 3; + } + + @Override + public void renderParticle(Tessellator tess, float interp, float x, float y, float z, float oX, float oZ) { + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + double dX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)interp; + double dY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)interp; + double dZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)interp; + + float pX = (float) ((this.prevPosX + (this.posX - this.prevPosX) * (double) interp - dX)); + float pY = (float) ((this.prevPosY + (this.posY - this.prevPosY) * (double) interp - dY)); + float pZ = (float) ((this.prevPosZ + (this.posZ - this.prevPosZ) * (double) interp - dZ)); + + ForgeDirection rot = this.dir.getRotation(ForgeDirection.UP); + double width = 0.0625 + ((this.particleAge + interp) / this.particleMaxAge) * 0.0625; + double girth = 0.125 * (1 - ((this.particleAge + interp) / this.particleMaxAge)); + + Color color = new Color(this.color).brighter(); + double brightener = 0.7D; + int r = (int) (255D - (255D - color.getRed()) * brightener); + int g = (int) (255D - (255D - color.getGreen()) * brightener); + int b = (int) (255D - (255D - color.getBlue()) * brightener); + + GL11.glColor3f(r / 255F, g / 255F, b / 255F); + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glTranslatef(pX, pY, pZ); + this.theRenderEngine.bindTexture(lava); + + tess.startDrawingQuads(); + tess.setNormal(0.0F, 1.0F, 0.0F); + tess.setBrightness(240); + + double dirXG = dir.offsetX * girth; + double dirZG = dir.offsetZ * girth; + double rotXW = rot.offsetX * width; + double rotZW = rot.offsetZ * width; + + double uMin = 0.5 - width; + double uMax = 0.5 + width; + double vMin = 0; + double vMax = length; + + double add = (int)(System.currentTimeMillis() / 100 % 16) / 16D; + + //lower back + tess.addVertexWithUV(rotXW, girth, rotZW, uMax, vMax + add + girth); + tess.addVertexWithUV(-rotXW, girth, -rotZW, uMin, vMax + add + girth); + tess.addVertexWithUV(-rotXW, -length, -rotZW, uMin, vMin + add); + tess.addVertexWithUV(rotXW, -length, rotZW, uMax, vMin + add); + + //lower front + tess.addVertexWithUV(dirXG + rotXW, 0, dirZG + rotZW, uMax, vMax + add); + tess.addVertexWithUV(dirXG - rotXW, 0, dirZG - rotZW, uMin, vMax + add); + tess.addVertexWithUV(dirXG - rotXW, -length, dirZG - rotZW, uMin, vMin + add); + tess.addVertexWithUV(dirXG + rotXW, -length, dirZG + rotZW, uMax, vMin + add); + + double wMin = 0; + double wMax = girth; + + //lower left + tess.addVertexWithUV(rotXW, girth, rotZW, wMin, vMax + add + girth); + tess.addVertexWithUV(dirXG + rotXW, 0, dirZG + rotZW, wMax, vMax + add); + tess.addVertexWithUV(dirXG + rotXW, -length, dirZG + rotZW, wMax, vMin + add); + tess.addVertexWithUV(rotXW, -length, rotZW, wMin, vMin + add); + + //lower right + tess.addVertexWithUV(-rotXW, girth, -rotZW, wMin, vMax + add + girth); + tess.addVertexWithUV(dirXG - rotXW, 0, dirZG - rotZW, wMax, vMax + add); + tess.addVertexWithUV(dirXG - rotXW, -length, dirZG - rotZW, wMax, vMin + add); + tess.addVertexWithUV(-rotXW, -length, -rotZW, wMin, vMin + add); + + double dirOX = dir.offsetX * offset; + double dirOZ = dir.offsetZ * offset; + + vMax = offset; + + //upper back + tess.addVertexWithUV(rotXW, 0, rotZW, uMax, vMax - add); + tess.addVertexWithUV(-rotXW, 0, -rotZW, uMin, vMax - add); + tess.addVertexWithUV(-rotXW - dirOX, base, -rotZW - dirOZ, uMin, vMin - add); + tess.addVertexWithUV(rotXW - dirOX, base, rotZW - dirOZ, uMax, vMin - add); + + //upper front + tess.addVertexWithUV(rotXW, girth, rotZW, uMax, vMax - add + 0.25); + tess.addVertexWithUV(-rotXW, girth, -rotZW, uMin, vMax - add + 0.25); + tess.addVertexWithUV(-rotXW - dirOX, base + girth, -rotZW - dirOZ, uMin, vMin - add + 0.25); + tess.addVertexWithUV(rotXW - dirOX, base + girth, rotZW - dirOZ, uMax, vMin - add + 0.25); + + //upper left + tess.addVertexWithUV(rotXW, 0, rotZW, wMax, vMax - add + 0.75); + tess.addVertexWithUV(rotXW, girth, rotZW, wMin, vMax - add + 0.75); + tess.addVertexWithUV(rotXW - dirOX, base + girth, rotZW - dirOZ, wMin, vMin - add + 0.75); + tess.addVertexWithUV(rotXW - dirOX, base, rotZW - dirOZ, wMax, vMin - add + 0.75); + + //upper right + tess.addVertexWithUV(-rotXW, 0, -rotZW, wMax, vMax - add + 0.75); + tess.addVertexWithUV(-rotXW, girth, -rotZW, wMin, vMax - add + 0.75); + tess.addVertexWithUV(-rotXW - dirOX, base + girth, -rotZW - dirOZ, wMin, vMin - add + 0.75); + tess.addVertexWithUV(-rotXW - dirOX, base, -rotZW - dirOZ, wMax, vMin - add + 0.75); + + vMax = 0.125F; + + //bend + tess.addVertexWithUV(dirXG + rotXW, 0, dirZG + rotZW, uMax, vMin + add + 0.75); + tess.addVertexWithUV(dirXG - rotXW, 0, dirZG - rotZW, uMin, vMin + add + 0.75); + tess.addVertexWithUV(-rotXW, girth, -rotZW, uMin, vMax + add + 0.75); + tess.addVertexWithUV(rotXW, girth, rotZW, uMax, vMax + add + 0.75); + + tess.draw(); + + + GL11.glColor3f(1F, 1F, 1F); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/hbm/particle/ParticleRBMKMush.java b/src/main/java/com/hbm/particle/ParticleRBMKMush.java index 81a25bfcc..cea193113 100644 --- a/src/main/java/com/hbm/particle/ParticleRBMKMush.java +++ b/src/main/java/com/hbm/particle/ParticleRBMKMush.java @@ -58,7 +58,7 @@ public class ParticleRBMKMush extends EntityFX { return 3; } - public void renderParticle(Tessellator tessellaator, float p_70539_2_, float x, float y, float z, float sx, float sz) { + public void renderParticle(Tessellator tessellator, float p_70539_2_, float x, float y, float z, float sx, float sz) { this.theRenderEngine.bindTexture(texture); @@ -80,21 +80,21 @@ public class ParticleRBMKMush extends EntityFX { boolean fog = GL11.glIsEnabled(GL11.GL_FOG); if(fog) GL11.glDisable(GL11.GL_FOG); - tessellaator.startDrawingQuads(); + tessellator.startDrawingQuads(); - tessellaator.setNormal(0.0F, 1.0F, 0.0F); - tessellaator.setBrightness(240); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.setBrightness(240); float scale = this.particleScale; float pX = (float) ((this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX)); float pY = (float) ((this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY)) + particleScale; float pZ = (float) ((this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ)); - tessellaator.addVertexWithUV((double) (pX - x * scale - sx * scale), (double) (pY - y * scale), (double) (pZ - z * scale - sz * scale), 1, (prog + 1) * frame); - tessellaator.addVertexWithUV((double) (pX - x * scale + sx * scale), (double) (pY + y * scale), (double) (pZ - z * scale + sz * scale), 1, prog * frame); - tessellaator.addVertexWithUV((double) (pX + x * scale + sx * scale), (double) (pY + y * scale), (double) (pZ + z * scale + sz * scale), 0, prog * frame); - tessellaator.addVertexWithUV((double) (pX + x * scale - sx * scale), (double) (pY - y * scale), (double) (pZ + z * scale - sz * scale), 0, (prog + 1) * frame); - tessellaator.draw(); + tessellator.addVertexWithUV((double) (pX - x * scale - sx * scale), (double) (pY - y * scale), (double) (pZ - z * scale - sz * scale), 1, (prog + 1) * frame); + tessellator.addVertexWithUV((double) (pX - x * scale + sx * scale), (double) (pY + y * scale), (double) (pZ - z * scale + sz * scale), 1, prog * frame); + tessellator.addVertexWithUV((double) (pX + x * scale + sx * scale), (double) (pY + y * scale), (double) (pZ + z * scale + sz * scale), 0, prog * frame); + tessellator.addVertexWithUV((double) (pX + x * scale - sx * scale), (double) (pY - y * scale), (double) (pZ + z * scale - sz * scale), 0, (prog + 1) * frame); + tessellator.draw(); if(fog) GL11.glEnable(GL11.GL_FOG); GL11.glPolygonOffset(0.0F, 0.0F); diff --git a/src/main/java/com/hbm/tileentity/TileEntityProxyBase.java b/src/main/java/com/hbm/tileentity/TileEntityProxyBase.java index 3d3cdfb8c..182e1f1bc 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityProxyBase.java +++ b/src/main/java/com/hbm/tileentity/TileEntityProxyBase.java @@ -1,11 +1,10 @@ package com.hbm.tileentity; import com.hbm.blocks.BlockDummyable; -import com.hbm.blocks.machine.BlockHadronAccess; -import com.hbm.tileentity.machine.TileEntityHadron; +import com.hbm.blocks.IProxyController; +import com.hbm.util.Compat; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; public class TileEntityProxyBase extends TileEntityLoadedBase { @@ -23,26 +22,16 @@ public class TileEntityProxyBase extends TileEntityLoadedBase { if(pos != null) { - TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]); - - if(te != null && te != this) - return te; + TileEntity te = Compat.getTileStandard(worldObj, pos[0], pos[1], pos[2]); + if(te != null && te != this) return te; } } - /// this spares me the hassle of registering a new child class TE that - /// aims at the right target /// - - if(this.getBlockType() instanceof BlockHadronAccess) { - ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); - - for(int i = 1; i < 3; i++) { - TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX * i, yCoord + dir.offsetY * i, zCoord + dir.offsetZ * i); - - if(te instanceof TileEntityHadron) { - return te; - } - } + if(this.getBlockType() instanceof IProxyController) { + IProxyController controller = (IProxyController) this.getBlockType(); + TileEntity tile = controller.getCore(worldObj, xCoord, yCoord, zCoord); + + if(tile != null && tile != this) return tile; } return null; diff --git a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java index e64e5c12f..4a1786e53 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java +++ b/src/main/java/com/hbm/tileentity/TileEntityProxyCombo.java @@ -55,7 +55,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy //fewer messy recursive operations public TileEntity getTile() { - if(tile == null) { + if(tile == null || tile.isInvalid()) { tile = this.getTE(); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java index 4e5c03498..6ee9c5d3b 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCrucible.java @@ -16,12 +16,15 @@ import com.hbm.inventory.material.NTMMaterial; import com.hbm.inventory.recipes.CrucibleRecipes; import com.hbm.inventory.recipes.CrucibleRecipes.CrucibleRecipe; import com.hbm.items.ModItems; +import com.hbm.packet.AuxParticlePacketNT; +import com.hbm.packet.PacketDispatcher; import com.hbm.tileentity.IConfigurableMachine; import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.CrucibleUtil; import api.hbm.tile.IHeatSource; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.GuiScreen; @@ -152,7 +155,19 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); Vec3 impact = Vec3.createVectorHelper(0, 0, 0); - 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(1), 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(2), impact); + + if(didPour != null) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "foundry"); + data.setInteger("color", didPour.material.moltenColor); + data.setByte("dir", (byte) dir.ordinal()); + data.setFloat("off", 0.625F); + data.setFloat("base", 0.625F); + data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875))); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord, zCoord + 0.5D + dir.offsetZ * 1.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50)); + + } } /* pour recipe stack */ @@ -178,7 +193,19 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro } Vec3 impact = Vec3.createVectorHelper(0, 0, 0); - 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(1), 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(2), impact); + + if(didPour != null) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "foundry"); + data.setInteger("color", didPour.material.moltenColor); + data.setByte("dir", (byte) dir.ordinal()); + data.setFloat("off", 0.625F); + data.setFloat("base", 0.625F); + data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875))); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 1.875D, yCoord, zCoord + 0.5D + dir.offsetZ * 1.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50)); + + } } /* clean up stacks */ diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java index e08be09b5..1414283fe 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryOutlet.java @@ -2,10 +2,13 @@ package com.hbm.tileentity.machine; import com.hbm.inventory.material.Mats; import com.hbm.inventory.material.Mats.MaterialStack; +import com.hbm.packet.AuxParticlePacketNT; +import com.hbm.packet.PacketDispatcher; import com.hbm.inventory.material.NTMMaterial; import com.hbm.util.CrucibleUtil; import api.hbm.block.ICrucibleAcceptor; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; @@ -76,7 +79,26 @@ public class TileEntityFoundryOutlet extends TileEntityFoundryBase { if(acc == null) return stack; - return acc.pour(world, mop[0].blockX, mop[0].blockY, mop[0].blockZ, mop[0].hitVec.xCoord, mop[0].hitVec.yCoord, mop[0].hitVec.zCoord, ForgeDirection.UP, stack); + MaterialStack didPour = acc.pour(world, mop[0].blockX, mop[0].blockY, mop[0].blockZ, mop[0].hitVec.xCoord, mop[0].hitVec.yCoord, mop[0].hitVec.zCoord, ForgeDirection.UP, stack); + + + if(stack != null) { + + ForgeDirection dir = side.getOpposite(); + double hitY = mop[0].blockY + 1; + + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "foundry"); + data.setInteger("color", stack.material.moltenColor); + data.setByte("dir", (byte) dir.ordinal()); + data.setFloat("off", 0.375F); + data.setFloat("base", 0F); + data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(hitY) - 0.875))); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D - dir.offsetX * 0.125, yCoord + 0.125, zCoord + 0.5D - dir.offsetZ * 0.125), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord, zCoord + 0.5, 50)); + + } + + return didPour; } @Override diff --git a/src/main/java/com/hbm/util/Compat.java b/src/main/java/com/hbm/util/Compat.java index ef36e6998..ff7da1c9d 100644 --- a/src/main/java/com/hbm/util/Compat.java +++ b/src/main/java/com/hbm/util/Compat.java @@ -199,9 +199,7 @@ public class Compat { /** A standard implementation of safely grabbing a tile entity without loading chunks, might have more fluff added to it later on. */ public static TileEntity getTileStandard(World world, int x, int y, int z) { - if(!world.getChunkProvider().chunkExists(x >> 4, z >> 4)) return null; - return world.getTileEntity(x, y, z); } }