From 515eb0026d62f93159f646cd980ccea756fd9f0b Mon Sep 17 00:00:00 2001 From: tterrag Date: Tue, 28 Jul 2020 23:57:29 -0400 Subject: [PATCH] Improve blaze burner particles - Now curl around blocks that are placed above - Spawns a burst of particles when fuel is added --- .../contraptions/particle/CubeParticle.java | 32 ++++++++++++++++++- .../particle/CubeParticleData.java | 15 ++++++--- .../burner/BlazeBurnerTileEntity.java | 19 +++++++---- .../resources/META-INF/accesstransformer.cfg | 5 ++- 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java index 2de6857b9..ad133bc4e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticle.java @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -80,6 +81,7 @@ public class CubeParticle extends Particle { }; protected float scale; + protected boolean hot; public CubeParticle(World world, double x, double y, double z, double motionX, double motionY, double motionZ) { super(world, x, y, z); @@ -92,12 +94,39 @@ public class CubeParticle extends Particle { public void setScale(float scale) { this.scale = scale; - this.setSize(scale, scale); + this.setSize(scale * 0.5f, scale * 0.5f); } public void averageAge(int age) { this.maxAge = (int) (age + (rand.nextDouble() * 2D - 1D) * 8); } + + public void setHot(boolean hot) { + this.hot = hot; + } + + private boolean billowing = false; + + @Override + public void tick() { + if (this.hot && this.age > 0) { + if (this.prevPosY == this.posY) { + billowing = true; + field_228343_B_ = false; // Prevent motion being ignored due to vertical collision + if (this.motionX == 0 && this.motionZ == 0) { + Vec3d diff = new Vec3d(new BlockPos(posX, posY, posZ)).add(0.5, 0.5, 0.5).subtract(posX, posY, posZ); + this.motionX = -diff.x * 0.1; + this.motionZ = -diff.z * 0.1; + } + this.motionX *= 1.1; + this.motionY *= 0.9; + this.motionZ *= 1.1; + } else if (billowing) { + this.motionY *= 1.2; + } + } + super.tick(); + } @Override public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo renderInfo, float p_225606_3_) { @@ -146,6 +175,7 @@ public class CubeParticle extends Particle { particle.setColor(data.r, data.g, data.b); particle.setScale(data.scale); particle.averageAge(data.avgAge); + particle.setHot(data.hot); return particle; } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java index 7e2ec3279..dc22608c7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java +++ b/src/main/java/com/simibubi/create/content/contraptions/particle/CubeParticleData.java @@ -28,12 +28,14 @@ public class CubeParticleData implements IParticleData, ICustomParticle type, PacketBuffer buffer) { - return new CubeParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readInt()); + return new CubeParticleData(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readInt(), buffer.readBoolean()); } }; @@ -42,17 +44,19 @@ public class CubeParticleData implements IParticleData, ICustomParticle 0.5) return; Vec3d color = randomColor(heatLevel); - spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.035F, 18), 0.03, 0.15); + spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.035F, 18, false), 0.03 * burstMult, 0.15 * burstMult); } else if (heatLevel == BlazeBurnerBlock.HeatLevel.KINDLED) { Vec3d color = randomColor(heatLevel); - spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.04F, 21), 0.05, 0.2); + spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.04F, 35, true), 0.05 * burstMult, 0.2 * burstMult); }else if (heatLevel == BlazeBurnerBlock.HeatLevel.SEETHING) { for (int i = 0; i < 2; i++) { if (r.nextDouble() > 0.6) return; Vec3d color = randomColor(heatLevel); - spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.045F, 24), 0.06, 0.22); + spawnParticle(new CubeParticleData((float) color.x,(float) color.y,(float) color.z, 0.045F, 35, true), 0.06 * burstMult, 0.22 * burstMult); } } } @@ -254,7 +259,7 @@ public class BlazeBurnerTileEntity extends SmartTileEntity { world.addOptionalParticle( particleData, (double) pos.getX() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, - (double) pos.getY() + 0.6D + random.nextDouble() / 10.0, + (double) pos.getY() + 0.6D + (random.nextDouble() / 4.0), (double) pos.getZ() + 0.5D + (random.nextDouble() * 2.0 - 1D) * spread, 0.0D, speed, diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 02bc0b9d4..5af4e7e17 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1 +1,4 @@ -public net.minecraft.network.play.ServerPlayNetHandler field_147365_f # floatingTickCount \ No newline at end of file +public net.minecraft.network.play.ServerPlayNetHandler field_147365_f # floatingTickCount + +# CubeParticle +protected net.minecraft.client.particle.Particle field_228343_B_ # collidedY \ No newline at end of file