From e2b1f6f4ca621ef0691aebdbb72a753a8e6a9149 Mon Sep 17 00:00:00 2001 From: CrazyPants Date: Sat, 13 Dec 2014 19:08:13 +0800 Subject: [PATCH] Fixed rendering of Zombie Gen bubbles and fluid plus fixed which pass facades are rendered in. --- .../conduit/render/ConduitBundleRenderer.java | 6 ++-- .../enderio/machine/AbstractMachineBlock.java | 1 + .../zombie/BlockZombieGenerator.java | 33 ++++++++++--------- .../machine/generator/zombie/BubbleFX.java | 32 ++++++++++++++++++ .../generator/zombie/TileZombieGenerator.java | 14 ++++++++ .../zombie/ZombieGeneratorRenderer.java | 28 +++++++++++----- .../util/ForgeDirectionOffsets.java | 8 +++++ 7 files changed, 96 insertions(+), 26 deletions(-) create mode 100644 src/main/java/crazypants/enderio/machine/generator/zombie/BubbleFX.java diff --git a/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java b/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java index b3c87878..213a7d3e 100644 --- a/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java +++ b/src/main/java/crazypants/enderio/conduit/render/ConduitBundleRenderer.java @@ -154,9 +154,11 @@ public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements } else if(facadeId != null) { bundle.setFacadeRenderAs(FacadeRenderState.FULL); - res = !facadeId.isOpaqueCube(); + boolean isFacadeOpaque = facadeId.isOpaqueCube(); + res = !isFacadeOpaque; - if(BlockConduitBundle.theRenderPass == 1) { + if((isFacadeOpaque && BlockConduitBundle.theRenderPass == 0) || + (!isFacadeOpaque && BlockConduitBundle.theRenderPass == 1)) { IBlockAccess origBa = rb.blockAccess; rb.blockAccess = new FacadeAccessWrapper(origBa); try { diff --git a/src/main/java/crazypants/enderio/machine/AbstractMachineBlock.java b/src/main/java/crazypants/enderio/machine/AbstractMachineBlock.java index 5aa631d7..d54e5d64 100644 --- a/src/main/java/crazypants/enderio/machine/AbstractMachineBlock.java +++ b/src/main/java/crazypants/enderio/machine/AbstractMachineBlock.java @@ -295,6 +295,7 @@ public abstract class AbstractMachineBlock exte } } + @SideOnly(Side.CLIENT) @Override public void randomDisplayTick(World world, int x, int y, int z, Random rand) { // If active, randomly throw some smoke around diff --git a/src/main/java/crazypants/enderio/machine/generator/zombie/BlockZombieGenerator.java b/src/main/java/crazypants/enderio/machine/generator/zombie/BlockZombieGenerator.java index 59a6ffe7..16f4524c 100644 --- a/src/main/java/crazypants/enderio/machine/generator/zombie/BlockZombieGenerator.java +++ b/src/main/java/crazypants/enderio/machine/generator/zombie/BlockZombieGenerator.java @@ -14,6 +14,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import crazypants.enderio.EnderIO; import crazypants.enderio.GuiHandler; import crazypants.enderio.ModObject; @@ -121,23 +122,23 @@ public class BlockZombieGenerator extends AbstractMachineBlock tooltip, EntityPlayer player, World world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); - if (te != null && te instanceof TileZombieGenerator) { - tooltip.add(((TileZombieGenerator)te).getFluidStored(ForgeDirection.UNKNOWN) + " mB"); - } + + @Override + public void getWailaInfo(List tooltip, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TileZombieGenerator) { + tooltip.add(((TileZombieGenerator) te).getFluidStored(ForgeDirection.UNKNOWN) + " mB"); } + } } diff --git a/src/main/java/crazypants/enderio/machine/generator/zombie/BubbleFX.java b/src/main/java/crazypants/enderio/machine/generator/zombie/BubbleFX.java new file mode 100644 index 00000000..026a45ae --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/generator/zombie/BubbleFX.java @@ -0,0 +1,32 @@ +package crazypants.enderio.machine.generator.zombie; + +import net.minecraft.client.particle.EntityBubbleFX; +import net.minecraft.world.World; + +public class BubbleFX extends EntityBubbleFX { + + private final double yLimit; + + public BubbleFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) { + super(world, x, y, z, motionX, motionY, motionZ); + setRBGColorF(0.6f, 0.6f, 0.5f); + yLimit = Math.floor(y) + 0.9; + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + motionY += 0.002D; + moveEntity(motionX, motionY, motionZ); + motionX *= 0.8500000238418579D; + motionY *= 0.8500000238418579D; + motionZ *= 0.8500000238418579D; + + if(particleMaxAge-- <= 0 || posY > yLimit) { + setDead(); + } + } + +} diff --git a/src/main/java/crazypants/enderio/machine/generator/zombie/TileZombieGenerator.java b/src/main/java/crazypants/enderio/machine/generator/zombie/TileZombieGenerator.java index 95b1fa14..5c5ebdf1 100644 --- a/src/main/java/crazypants/enderio/machine/generator/zombie/TileZombieGenerator.java +++ b/src/main/java/crazypants/enderio/machine/generator/zombie/TileZombieGenerator.java @@ -36,6 +36,8 @@ public class TileZombieGenerator extends AbstractGeneratorEntity implements IFlu private int ticksRemaingFuel; private boolean inPause; + int pass = 0; + public TileZombieGenerator() { super(new SlotDefinition(0, 0, 0)); } @@ -227,6 +229,18 @@ public class TileZombieGenerator extends AbstractGeneratorEntity implements IFlu active = nbtRoot.getBoolean("active"); } + @Override + public boolean shouldRenderInPass(int pass) { + this.pass = pass; + if(pass == 0) { + return true; + } + if(pass == 1) { + return fuelTank.getFluidAmount() > 0; + } + return false; + } + @Override public void readCommon(NBTTagCompound nbtRoot) { super.readCommon(nbtRoot); diff --git a/src/main/java/crazypants/enderio/machine/generator/zombie/ZombieGeneratorRenderer.java b/src/main/java/crazypants/enderio/machine/generator/zombie/ZombieGeneratorRenderer.java index 31fe3357..a3259851 100644 --- a/src/main/java/crazypants/enderio/machine/generator/zombie/ZombieGeneratorRenderer.java +++ b/src/main/java/crazypants/enderio/machine/generator/zombie/ZombieGeneratorRenderer.java @@ -37,12 +37,15 @@ public class ZombieGeneratorRenderer extends TileEntitySpecialRenderer implement int l1 = l % 65536; int l2 = l / 65536; Tessellator.instance.setColorOpaque_F(f, f, f); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2); GL11.glPushMatrix(); GL11.glTranslatef((float) x, (float) y, (float) z); - renderModel(gen.facing); - renderFluid(gen); + if(gen.pass == 0) { + renderModel(gen.facing); + } else if(gen.pass == 1) { + renderFluid(gen); + } GL11.glPopMatrix(); } @@ -57,14 +60,22 @@ public class ZombieGeneratorRenderer extends TileEntitySpecialRenderer implement Tessellator tes = Tessellator.instance; tes.startDrawingQuads(); - float fullness = (float) (tank.getFluidAmount()) / (tank.getCapacity()); + ForgeDirection facingDir = ForgeDirection.values()[gen.facing]; + double facingOffset = 0.075; + BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.96, 0.85); - bb = bb.scale(1, 0.85 * fullness, 1); - float ty = -(0.85f - (bb.maxY - bb.minY)) / 2; + float fullness = (float) (tank.getFluidAmount()) / (tank.getCapacity()); + Vector3d absFac = ForgeDirectionOffsets.absolueOffset(facingDir); + + double scaleX = absFac.x == 0 ? 0.95 : 1 - facingOffset / 2; + double scaleY = 0.85 * fullness; + double scaleZ = absFac.z == 0 ? 0.95 : 1 - facingOffset / 2; + bb = bb.scale(scaleX, 0.85 * fullness, scaleZ); - Vector3d offset = ForgeDirectionOffsets.offsetScaled(ForgeDirection.values()[gen.facing], -0.075); - bb = bb.translate((float)offset.x, ty, (float)offset.z); + float ty = -(0.85f - (bb.maxY - bb.minY)) / 2; + Vector3d transOffset = ForgeDirectionOffsets.offsetScaled(facingDir, -facingOffset); + bb = bb.translate((float) transOffset.x, ty, (float) transOffset.z); int brightness; if(gen.getWorldObj() == null) { @@ -80,6 +91,7 @@ public class ZombieGeneratorRenderer extends TileEntitySpecialRenderer implement GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); tes.draw(); GL11.glDepthMask(true); diff --git a/src/main/java/crazypants/util/ForgeDirectionOffsets.java b/src/main/java/crazypants/util/ForgeDirectionOffsets.java index 41f21dcd..d515900e 100644 --- a/src/main/java/crazypants/util/ForgeDirectionOffsets.java +++ b/src/main/java/crazypants/util/ForgeDirectionOffsets.java @@ -27,6 +27,14 @@ public final class ForgeDirectionOffsets { return res; } + public static Vector3d absolueOffset(ForgeDirection dir) { + Vector3d res = forDirCopy(dir); + res.x = Math.abs(res.x); + res.y = Math.abs(res.y); + res.z = Math.abs(res.z); + return res; + } + public ForgeDirection closest(float x, float y, float z) { float ax = Math.abs(x); float ay = Math.abs(y);