TOREX flash overlay

This commit is contained in:
Bob 2023-08-21 22:09:54 +02:00
parent ae44c8a2a4
commit 450e519234
7 changed files with 121 additions and 21 deletions

View File

@ -5,10 +5,12 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.BombConfig;
import com.hbm.entity.effect.EntityNukeCloudSmall;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.EntityNukeExplosionMK5;
import com.hbm.interfaces.IBomb;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.bomb.TileEntityNukeBoy;
import com.hbm.util.TrackerUtil;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
@ -124,7 +126,13 @@ public class NukeBoy extends BlockContainer implements IBomb {
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.boyRadius, x + 0.5, y + 0.5, z + 0.5));
world.spawnEntityInWorld(EntityNukeCloudSmall.statFac(world, x, y, z, BombConfig.boyRadius));
//world.spawnEntityInWorld(EntityNukeCloudSmall.statFac(world, x, y, z, BombConfig.boyRadius));
EntityNukeTorex torex = new EntityNukeTorex(world);
torex.setPositionAndRotation(x + 0.5, y + 1, z + 0.5, 0, 0);
torex.getDataWatcher().updateObject(10, 1.5F);
world.spawnEntityInWorld(torex);
TrackerUtil.setTrackingRange(world, torex, 1000);
}
return false;
}

View File

@ -151,7 +151,7 @@ public class EntityNukeTorex extends Entity {
if(life > fadeOut) {
float fac = (float)(life - fadeOut) / (float)(lifetime - fadeOut);
return 1F - fac * fac;
return 1F - fac;
}
return 1.0F;

View File

@ -2,15 +2,22 @@ package com.hbm.items.tool;
import java.util.List;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.lib.Library;
import com.hbm.util.TrackerUtil;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.entity.EntityTracker;
import net.minecraft.entity.EntityTrackerEntry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public class ItemWandD extends Item {
@ -32,7 +39,7 @@ public class ItemWandD extends Item {
vnt.setSFX(new ExplosionEffectStandard());
vnt.explode();*/
PollutionHandler.incrementPollution(world, pos.blockX, pos.blockY, pos.blockZ, PollutionType.SOOT, 15);
//PollutionHandler.incrementPollution(world, pos.blockX, pos.blockY, pos.blockZ, PollutionType.SOOT, 15);
/*TimeAnalyzer.startCount("setBlock");
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.dirt);
@ -54,15 +61,16 @@ public class ItemWandD extends Item {
tom.destructionRange = 600;
world.spawnEntityInWorld(tom);*/
/*EntityNukeTorex torex = new EntityNukeTorex(world);
EntityNukeTorex torex = new EntityNukeTorex(world);
torex.setPositionAndRotation(pos.blockX, pos.blockY + 1, pos.blockZ, 0, 0);
torex.getDataWatcher().updateObject(10, 1.5F);
world.spawnEntityInWorld(torex);
EntityTracker entitytracker = ((WorldServer) world).getEntityTracker();
/*EntityTracker entitytracker = ((WorldServer) world).getEntityTracker();
IntHashMap map = ReflectionHelper.getPrivateValue(EntityTracker.class, entitytracker, "trackedEntityIDs", "field_72794_c");
EntityTrackerEntry entry = (EntityTrackerEntry) map.lookup(torex.getEntityId());
entry.blocksDistanceThreshold = 1000;
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, 150, pos.blockX, pos.blockY + 1, pos.blockZ));*/
entry.blocksDistanceThreshold = 1000;*/
TrackerUtil.setTrackingRange(world, torex, 1000);
//world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, 150, pos.blockX, pos.blockY + 1, pos.blockZ));
//DungeonToolbox.generateBedrockOreWithChance(world, world.rand, pos.blockX, pos.blockZ, EnumBedrockOre.TITANIUM, new FluidStack(Fluids.SULFURIC_ACID, 500), 2, 1);

View File

@ -1,7 +1,6 @@
package com.hbm.main;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
@ -18,7 +17,6 @@ import com.hbm.blocks.rail.IRailNTM.MoveContext;
import com.hbm.blocks.rail.IRailNTM.RailCheckType;
import com.hbm.blocks.rail.IRailNTM.RailContext;
import com.hbm.config.GeneralConfig;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.mob.EntityHunterChopper;
import com.hbm.entity.projectile.EntityChopperMine;
import com.hbm.entity.train.EntityRailCarRidable;
@ -147,11 +145,38 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
public class ModEventHandlerClient {
public static int flashTimer;
@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent.Pre event) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
/// NUKE FLASH ///
if(event.type == ElementType.CROSSHAIRS && flashTimer > 0) {
int width = event.resolution.getScaledWidth();
int height = event.resolution.getScaledHeight();
Tessellator tess = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.0F);
GL11.glDepthMask(false);
tess.startDrawingQuads();
float brightness = (flashTimer - event.partialTicks) / 200F;
tess.setColorRGBA_F(1F, 1F, 1F, brightness * 0.8F);
tess.addVertex(width, 0, 0);
tess.addVertex(0, 0, 0);
tess.addVertex(0, height, 0);
tess.addVertex(width, height, 0);
tess.draw();
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDepthMask(true);
return;
}
/// HANDLE GUN OVERLAYS ///
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemHUD) {
((IItemHUD)player.getHeldItem().getItem()).renderHUD(event, event.type, player, player.getHeldItem());
@ -196,18 +221,6 @@ public class ModEventHandlerClient {
}
}
List<EntityNukeTorex> torex = world.getEntitiesWithinAABB(EntityNukeTorex.class, player.boundingBox.expand(100, 100, 100));
if(!torex.isEmpty()) {
EntityNukeTorex t = torex.get(0);
List<String> text = new ArrayList();
text.add("Speed: " + t.getSimulationSpeed());
text.add("Alpha: " + t.getAlpha());
text.add("Age: " + t.ticksExisted + " / " + t.getMaxAge());
text.add("Clouds: " + t.cloudlets.size());
ILookOverlay.printGeneric(event, "DEBUG", 0xff0000, 0x4040000, text);
}
/*List<String> text = new ArrayList();
text.add("IMPACT: " + ImpactWorldHandler.getImpactForClient(world));
text.add("DUST: " + ImpactWorldHandler.getDustForClient(world));
@ -1250,6 +1263,8 @@ public class ModEventHandlerClient {
client.sendQueue.addToSendQueue(new C0CPacketInput(client.moveStrafing, client.moveForward, client.movementInput.jump, client.movementInput.sneak));
}
}
if(event.phase == Phase.START) if(flashTimer > 0) flashTimer--;
}
@SubscribeEvent

View File

@ -2,6 +2,7 @@ package com.hbm.render.entity.effect;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Random;
import org.lwjgl.opengl.GL11;
@ -9,6 +10,7 @@ import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.effect.EntityNukeTorex.Cloudlet;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.main.ModEventHandlerClient;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.OpenGlHelper;
@ -23,6 +25,7 @@ import net.minecraft.util.Vec3;
public class RenderTorex extends Render {
private static final ResourceLocation cloudlet = new ResourceLocation(RefStrings.MODID + ":textures/particle/particle_base.png");
private static final ResourceLocation flash = new ResourceLocation(RefStrings.MODID + ":textures/particle/flare.png");
@Override
public void doRender(Entity entity, double x, double y, double z, float f0, float interp) {
@ -31,6 +34,8 @@ public class RenderTorex extends Render {
GL11.glTranslated(x, y, z);
EntityNukeTorex cloud = (EntityNukeTorex)entity;
cloudletWrapper(cloud, interp);
if(cloud.ticksExisted < 101) flashWrapper(cloud, interp);
if(cloud.ticksExisted < 10 && ModEventHandlerClient.flashTimer < 100) ModEventHandlerClient.flashTimer = 200;
GL11.glPopMatrix();
}
@ -81,6 +86,43 @@ public class RenderTorex extends Render {
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
private void flashWrapper(EntityNukeTorex cloud, float interp) {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glDepthMask(false);
RenderHelper.disableStandardItemLighting();
bindTexture(flash);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
double age = Math.min(cloud.ticksExisted + interp, 100);
float alpha = (float) ((100D - age) / 100F);
Random rand = new Random(cloud.getEntityId());
for(int i = 0; i < 3; i++) {
float x = (float) (rand.nextGaussian() * 0.5F * cloud.rollerSize);
float y = (float) (rand.nextGaussian() * 0.5F * cloud.rollerSize);
float z = (float) (rand.nextGaussian() * 0.5F * cloud.rollerSize);
tessellateFlash(tess, x, y + cloud.coreHeight, z, (float) (10 * cloud.rollerSize), alpha, interp);
}
tess.draw();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.enableStandardItemLighting();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
private void tessellateCloudlet(Tessellator tess, double posX, double posY, double posZ, Cloudlet cloud, float interp) {
@ -104,6 +146,23 @@ public class RenderTorex extends Render {
}
private void tessellateFlash(Tessellator tess, double posX, double posY, double posZ, float scale, float alpha, float interp) {
float f1 = ActiveRenderInfo.rotationX;
float f2 = ActiveRenderInfo.rotationZ;
float f3 = ActiveRenderInfo.rotationYZ;
float f4 = ActiveRenderInfo.rotationXY;
float f5 = ActiveRenderInfo.rotationXZ;
tess.setColorRGBA_F(1F, 1F, 1F, alpha);
tess.addVertexWithUV((double) (posX - f1 * scale - f3 * scale), (double) (posY - f5 * scale), (double) (posZ - f2 * scale - f4 * scale), 1, 1);
tess.addVertexWithUV((double) (posX - f1 * scale + f3 * scale), (double) (posY + f5 * scale), (double) (posZ - f2 * scale + f4 * scale), 1, 0);
tess.addVertexWithUV((double) (posX + f1 * scale + f3 * scale), (double) (posY + f5 * scale), (double) (posZ + f2 * scale + f4 * scale), 0, 0);
tess.addVertexWithUV((double) (posX + f1 * scale - f3 * scale), (double) (posY - f5 * scale), (double) (posZ + f2 * scale - f4 * scale), 0, 1);
}
@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
return null;

View File

@ -202,6 +202,7 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
slots[1].stackSize++;
}
this.amountLoaded--;
this.markChanged();
}
}

View File

@ -41,4 +41,13 @@ public class TrackerUtil {
entry.ticks = 0;
}
}
public static void setTrackingRange(World world, Entity e, int range) {
if(world instanceof WorldServer) {
WorldServer server = (WorldServer) world;
EntityTrackerEntry entry = getTrackerEntry(server, e.getEntityId());
entry.blocksDistanceThreshold = range;
}
}
}