diff --git a/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java b/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java index 5e7d9187f..5d67bb325 100644 --- a/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java +++ b/src/main/java/com/hbm/inventory/fluid/tank/FluidTank.java @@ -53,6 +53,10 @@ public class FluidTank { public void setTankType(FluidType type) { + if(type == null) { + type = Fluids.NONE; + } + if(this.type == type) return; @@ -85,16 +89,16 @@ public class FluidTank { } //Called on TE update - public void updateTank(TileEntity te) { + @Deprecated public void updateTank(TileEntity te) { updateTank(te, 100); } - public void updateTank(TileEntity te, int range) { + @Deprecated public void updateTank(TileEntity te, int range) { updateTank(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj().provider.dimensionId, range); } - public void updateTank(int x, int y, int z, int dim) { + @Deprecated public void updateTank(int x, int y, int z, int dim) { updateTank(x, y, z, dim, 100); } - public void updateTank(int x, int y, int z, int dim, int range) { + @Deprecated public void updateTank(int x, int y, int z, int dim, int range) { PacketDispatcher.wrapper.sendToAllAround(new TEFluidPacket(x, y, z, fluid, index, type), new TargetPoint(dim, x, y, z, range)); } diff --git a/src/main/java/com/hbm/packet/TEFluidPacket.java b/src/main/java/com/hbm/packet/TEFluidPacket.java index 078729c9f..49338eab5 100644 --- a/src/main/java/com/hbm/packet/TEFluidPacket.java +++ b/src/main/java/com/hbm/packet/TEFluidPacket.java @@ -11,6 +11,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; +@Deprecated public class TEFluidPacket implements IMessage { int x; diff --git a/src/main/java/com/hbm/particle/psys/engine/PSysFX.java b/src/main/java/com/hbm/particle/psys/engine/PSysFX.java index 4abb6412c..685f17835 100644 --- a/src/main/java/com/hbm/particle/psys/engine/PSysFX.java +++ b/src/main/java/com/hbm/particle/psys/engine/PSysFX.java @@ -2,6 +2,7 @@ package com.hbm.particle.psys.engine; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; /** @@ -10,7 +11,7 @@ import net.minecraft.world.World; * @author hbm */ @SideOnly(Side.CLIENT) -public class PSysFX { +public abstract class PSysFX { public World world; public double posX; @@ -19,14 +20,62 @@ public class PSysFX { public double prevPosX; public double prevPosY; public double prevPosZ; - public double motionX; - public double motionY; - public double motionZ; public static double interpPosX; public static double interpPosY; public static double interpPosZ; - - public PSysFX() { + public AxisAlignedBB boundingBox; + public int particleAge; + public int particleMaxAge; + public boolean isExpired = false; + public boolean shouldExpireWhenUnloaded = true; + public boolean isUnloaded = false; + + public PSysFX(World world, double x, double y, double z) { + this.world = world; + this.posX = x; + this.posY = y; + this.posZ = z; + } + + public void updateParticle() { + this.prevPosX = posX; + this.prevPosY = posY; + this.prevPosZ = posZ; + this.isUnloaded = !world.getChunkProvider().chunkExists((int) Math.floor(posX) >> 4, (int) Math.floor(posZ) >> 4); + this.particleAge++; + + if(this.particleAge >= this.particleMaxAge) { + this.expire(); + } + + if(this.shouldExpireWhenUnloaded && this.isUnloaded) { + this.expire(); + } + } + + public abstract void renderParticle(); + + public AxisAlignedBB getBoundingBox() { + return this.boundingBox; + } + + public void setBoundingBox(AxisAlignedBB bb) { + this.boundingBox = bb; + } + + protected void setPosToAABB() { + AxisAlignedBB aabb = this.getBoundingBox(); + this.posX = (aabb.minX + aabb.maxX) / 2.0D; + this.posY = aabb.minY; + this.posZ = (aabb.minZ + aabb.maxZ) / 2.0D; + } + + public void expire() { + this.isExpired = true; + } + + public void setExpireOnUnload(boolean expire) { + this.shouldExpireWhenUnloaded = expire; } } diff --git a/src/main/java/com/hbm/particle/psys/engine/PSysFXMoving.java b/src/main/java/com/hbm/particle/psys/engine/PSysFXMoving.java new file mode 100644 index 000000000..9922b3575 --- /dev/null +++ b/src/main/java/com/hbm/particle/psys/engine/PSysFXMoving.java @@ -0,0 +1,87 @@ +package com.hbm.particle.psys.engine; + +import java.util.List; + +import com.hbm.lib.Library; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public abstract class PSysFXMoving extends PSysFX { + + public double motionX; + public double motionY; + public double motionZ; + boolean noClip = false; + /* using the forgedirection's ordinal as an index, this tells us what side of a block the particle has collided with */ + public boolean collisionData[] = new boolean[6]; + + public PSysFXMoving(World world, double x, double y, double z, double mX, double mY, double mZ) { + super(world, x, y, z); + this.motionX = mX; + this.motionY = mY; + this.motionZ = mZ; + } + + public double getParticleGravity() { + return 0.04D; + } + + public double getParticleDrag() { + return 0.98D; + } + + public void updateParticle() { + super.updateParticle(); + + if(!this.isUnloaded) { + this.motionX -= this.getParticleGravity(); + this.motionX *= this.getParticleDrag(); + this.motionY *= this.getParticleDrag(); + this.motionZ *= this.getParticleDrag(); + + this.move(motionX, motionY, motionZ); + } + } + + public void move(double x, double y, double z) { + + double x0 = x; + double y0 = y; + double z0 = z; + + this.collisionData = new boolean[6]; + + if(!noClip) { + List list = this.world.getCollidingBoundingBoxes(null, this.getBoundingBox().expand(x, y, z)); + + for(AxisAlignedBB aabb : list) y = aabb.calculateYOffset(this.getBoundingBox(), y); + this.setBoundingBox(this.getBoundingBox().offset(0.0D, y, 0.0D)); + + for(AxisAlignedBB aabb : list) x = aabb.calculateXOffset(this.getBoundingBox(), x); + this.setBoundingBox(this.getBoundingBox().offset(x, 0.0D, 0.0D)); + + for(AxisAlignedBB aabb : list) z = aabb.calculateZOffset(this.getBoundingBox(), z); + this.setBoundingBox(this.getBoundingBox().offset(0.0D, 0.0D, z)); + + } else { + this.setBoundingBox(this.getBoundingBox().offset(x, y, z)); + } + + this.setPosToAABB(); + + if(x0 != x && x > 0) this.collisionData[Library.NEG_X.ordinal()] = true; + if(x0 != x && x < 0) this.collisionData[Library.POS_X.ordinal()] = true; + if(y0 != y && y > 0) this.collisionData[Library.NEG_Y.ordinal()] = true; + if(y0 != y && y < 0) this.collisionData[Library.POS_Y.ordinal()] = true; + if(z0 != z && z > 0) this.collisionData[Library.NEG_Z.ordinal()] = true; + if(z0 != z && z < 0) this.collisionData[Library.POS_Z.ordinal()] = true; + + if(x0 != x) this.motionX = 0.0D; + if(y0 != y) this.motionY = 0.0D; + if(z0 != z) this.motionZ = 0.0D; + } +} diff --git a/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java b/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java index 6c46b7b19..8f2742ad3 100644 --- a/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java +++ b/src/main/java/com/hbm/particle/psys/engine/ParticleEngine.java @@ -29,17 +29,17 @@ public class ParticleEngine { } public void updateParticles() { - + for(FXLayer layer : layers) layer.updateLayer(); } public void renderParticles(float interp) { - + for(FXLayer layer : layers) layer.renderLayer(interp); } public static class FXLayer { protected ResourceLocation batchTexture; - protected List particles; + protected List particles; public FXLayer() { } @@ -51,7 +51,7 @@ public class ParticleEngine { } - protected void renderLayer() { + protected void renderLayer(float interp) { } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineMixer.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineMixer.java index 9204a1dbd..69a0122e7 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineMixer.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineMixer.java @@ -145,23 +145,11 @@ public class TileEntityMachineMixer extends TileEntityMachineBase implements INB if(recipe == null) return false; - if(recipe.input1 != null) { - - if(recipe.input1.type != tanks[0].getTankType()) { - tanks[0].setTankType(recipe.input1.type); - } - - if(tanks[0].getFill() < recipe.input1.fill) return false; - } - - if(recipe.input2 != null) { - - if(recipe.input2.type != tanks[1].getTankType()) { - tanks[1].setTankType(recipe.input2.type); - } - - if(tanks[1].getFill() < recipe.input2.fill) return false; - } + tanks[0].setTankType(recipe.input1.type); + tanks[1].setTankType(recipe.input2.type); + + if(recipe.input1 != null && tanks[0].getFill() < recipe.input1.fill) return false; + if(recipe.input2 != null && tanks[1].getFill() < recipe.input2.fill) return false; /* simplest check would usually go first, but fluid checks also do the setup and we want that to happen even without power */ if(this.power < getConsumption()) return false;