spiralpoint visualization, less console spam from pollution handler

This commit is contained in:
Boblet 2023-08-31 15:50:42 +02:00
parent 07cf03b365
commit 2ff5096562
4 changed files with 102 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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");

View File

@ -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();
}
}