From 2ff5096562656f083f73047dfdb0751f6fcb1cd8 Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 31 Aug 2023 15:50:42 +0200 Subject: [PATCH] spiralpoint visualization, less console spam from pollution handler --- .../explosion/ExplosionNukeRayBatched.java | 17 ++++- .../handler/pollution/PollutionHandler.java | 7 +- src/main/java/com/hbm/main/ClientProxy.java | 9 +++ .../com/hbm/particle/ParticleDebugLine.java | 72 +++++++++++++++++++ 4 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/hbm/particle/ParticleDebugLine.java diff --git a/src/main/java/com/hbm/explosion/ExplosionNukeRayBatched.java b/src/main/java/com/hbm/explosion/ExplosionNukeRayBatched.java index f66c5f047..f8cc562fe 100644 --- a/src/main/java/com/hbm/explosion/ExplosionNukeRayBatched.java +++ b/src/main/java/com/hbm/explosion/ExplosionNukeRayBatched.java @@ -6,10 +6,14 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import com.hbm.packet.AuxParticlePacketNT; +import com.hbm.packet.PacketDispatcher; import com.hbm.util.fauxpointtwelve.BlockPos; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; @@ -76,6 +80,8 @@ public class ExplosionNukeRayBatched { } public void collectTip(int count) { + + //count = Math.min(count, 10); int amountProcessed = 0; @@ -119,7 +125,16 @@ public class ExplosionNukeRayBatched { chunkCoords.add(chunkPos); } - if(res <= 0 || i + 1 >= this.length) { + if(res <= 0 || i + 1 >= this.length || i == length - 1) { + + /*NBTTagCompound fx = new NBTTagCompound(); + fx.setString("type", "debugline"); + fx.setDouble("mX", vec.xCoord * i); + fx.setDouble("mY", vec.yCoord * i); + fx.setDouble("mZ", vec.zCoord * i); + fx.setInteger("color", 0xff0000); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(fx, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 200));*/ + break; } } diff --git a/src/main/java/com/hbm/handler/pollution/PollutionHandler.java b/src/main/java/com/hbm/handler/pollution/PollutionHandler.java index 6ddf72eec..4ff3b70c1 100644 --- a/src/main/java/com/hbm/handler/pollution/PollutionHandler.java +++ b/src/main/java/com/hbm/handler/pollution/PollutionHandler.java @@ -142,8 +142,11 @@ public class PollutionHandler { try { if(!pollutionFile.getParentFile().exists()) pollutionFile.getParentFile().mkdirs(); if(!pollutionFile.exists()) pollutionFile.createNewFile(); - NBTTagCompound data = perWorld.get(world).writeToNBT(); - CompressedStreamTools.writeCompressed(data, new FileOutputStream(pollutionFile)); + PollutionPerWorld ppw = perWorld.get(world); + if(ppw != null) { + NBTTagCompound data = ppw.writeToNBT(); + CompressedStreamTools.writeCompressed(data, new FileOutputStream(pollutionFile)); + } } catch(Exception ex) { System.out.println("Failed to write " + pollutionFile.getAbsolutePath()); ex.printStackTrace(); diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 4c469d776..49b3aae01 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -1833,6 +1833,15 @@ public class ClientProxy extends ServerProxy { Minecraft.getMinecraft().effectRenderer.addEffect(text); } + if("debugline".equals(type)) { + double mX = data.getDouble("mX"); + double mY = data.getDouble("mY"); + double mZ = data.getDouble("mZ"); + int color = data.getInteger("color"); + ParticleDebugLine text = new ParticleDebugLine(world, x, y, z, mX, mY, mZ, color); + Minecraft.getMinecraft().effectRenderer.addEffect(text); + } + if("network".equals(type)) { ParticleDebug debug = null; double mX = data.getDouble("mX"); diff --git a/src/main/java/com/hbm/particle/ParticleDebugLine.java b/src/main/java/com/hbm/particle/ParticleDebugLine.java new file mode 100644 index 000000000..5207e7658 --- /dev/null +++ b/src/main/java/com/hbm/particle/ParticleDebugLine.java @@ -0,0 +1,72 @@ +package com.hbm.particle; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +public class ParticleDebugLine extends EntityFX { + + int color; + + public ParticleDebugLine(World world, double x, double y, double z, double lx, double ly, double lz, int color) { + super(world, x, y, z, lx, ly, lz); + this.motionX = lx; + this.motionY = ly; + this.motionZ = lz; + this.color = color; + this.particleMaxAge = 60; + } + + @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 tx, float tz) { + + double pX = this.prevPosX + (this.posX - this.prevPosX) * (double) interp - interpPosX; + double pY = this.prevPosY + (this.posY - this.prevPosY) * (double) interp - interpPosY; + double pZ = this.prevPosZ + (this.posZ - this.prevPosZ) * (double) interp - interpPosZ; + + double mX = pX + motionX; + double mY = pY + motionY; + double mZ = pZ + motionZ; + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_COLOR_MATERIAL); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_POINT_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA); + + tess.startDrawing(GL11.GL_LINES); + tess.setBrightness((int) (240 - (240 * (this.particleAge + interp) / this.particleMaxAge))); + tess.setColorOpaque_I(color); + tess.addVertex(pX, pY, pZ); + tess.addVertex(mX, mY, mZ); + tess.draw(); + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_POINT_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } +}