From 26c97ef9ecb5628cdfd824ca1c64e0f4dcbdf6ca Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 22 Nov 2023 15:26:56 +0100 Subject: [PATCH] more missile fun --- .../missile/EntityMissileAntiBallistic.java | 7 + .../entity/missile/EntityMissileBaseNT.java | 12 +- .../entity/missile/EntityMissileCustom.java | 332 +++--------------- .../hbm/textures/items/coal_eternal.png | Bin 0 -> 429 bytes 4 files changed, 70 insertions(+), 281 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/items/coal_eternal.png diff --git a/src/main/java/com/hbm/entity/missile/EntityMissileAntiBallistic.java b/src/main/java/com/hbm/entity/missile/EntityMissileAntiBallistic.java index 5d6e40d2a..40083b324 100644 --- a/src/main/java/com/hbm/entity/missile/EntityMissileAntiBallistic.java +++ b/src/main/java/com/hbm/entity/missile/EntityMissileAntiBallistic.java @@ -16,6 +16,13 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; +/* + * COME ON + * STEP 1: GET 24 EGGS + * STEP 2: FUCK EVERY EGG + * STEP 3: BLOW UP ALL THE FUCKING EGGS + * AND FROM THE ASHES THE MOTHER OF ALL OMELETTES WILL BE BORN! + */ public class EntityMissileAntiBallistic extends Entity implements IRadarDetectable { int activationTimer; diff --git a/src/main/java/com/hbm/entity/missile/EntityMissileBaseNT.java b/src/main/java/com/hbm/entity/missile/EntityMissileBaseNT.java index 75a1d265b..243835d76 100644 --- a/src/main/java/com/hbm/entity/missile/EntityMissileBaseNT.java +++ b/src/main/java/com/hbm/entity/missile/EntityMissileBaseNT.java @@ -65,8 +65,8 @@ public abstract class EntityMissileBaseNT extends EntityThrowableInterp implemen @Override protected void entityInit() { + super.entityInit(); init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY)); - this.dataWatcher.addObject(8, Integer.valueOf(this.health)); } @Override @@ -112,8 +112,7 @@ public abstract class EntityMissileBaseNT extends EntityThrowableInterp implemen loadNeighboringChunks((int) Math.floor(posX / 16), (int) Math.floor(posZ / 16)); } else { - Vec3 vec = Vec3.createVectorHelper(motionX, motionY, motionZ).normalize(); - MainRegistry.proxy.particleControl(posX - vec.xCoord, posY - vec.yCoord, posZ - vec.zCoord, 2); + this.spawnContrail(); } float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); @@ -123,6 +122,11 @@ public abstract class EntityMissileBaseNT extends EntityThrowableInterp implemen while(this.rotationYaw - this.prevRotationYaw < -180.0F) this.prevRotationYaw -= 360.0F; while(this.rotationYaw - this.prevRotationYaw >= 180.0F) this.prevRotationYaw += 360.0F; } + + protected void spawnContrail() { + Vec3 vec = Vec3.createVectorHelper(motionX, motionY, motionZ).normalize(); + MainRegistry.proxy.particleControl(posX - vec.xCoord, posY - vec.yCoord, posZ - vec.zCoord, 2); + } @Override public void readEntityFromNBT(NBTTagCompound nbt) { @@ -180,7 +184,7 @@ public abstract class EntityMissileBaseNT extends EntityThrowableInterp implemen } } - private void killMissile() { + protected void killMissile() { ExplosionLarge.explode(worldObj, posX, posY, posZ, 5, true, false, true); ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075); ExplosionLarge.spawnMissileDebris(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 0.25, getDebris(), getDebrisRareDrop()); diff --git a/src/main/java/com/hbm/entity/missile/EntityMissileCustom.java b/src/main/java/com/hbm/entity/missile/EntityMissileCustom.java index 0fed51411..c8ed518e2 100644 --- a/src/main/java/com/hbm/entity/missile/EntityMissileCustom.java +++ b/src/main/java/com/hbm/entity/missile/EntityMissileCustom.java @@ -21,99 +21,43 @@ import com.hbm.items.weapon.ItemMissile.WarheadType; import com.hbm.main.MainRegistry; import api.hbm.entity.IRadarDetectable; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; -import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeChunkManager; -import net.minecraftforge.common.ForgeChunkManager.Ticket; -import net.minecraftforge.common.ForgeChunkManager.Type; -public class EntityMissileCustom extends Entity implements IChunkLoader, IRadarDetectable { +public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLoader, IRadarDetectable { - int startX; - int startZ; - int targetX; - int targetZ; - double velocity; - double decelY; - double accelXZ; - float fuel; - float consumption; - private Ticket loaderTicket; - public int health = 50; - MissileStruct template; + protected float fuel; + protected float consumption; - public EntityMissileCustom(World p_i1582_1_) { - super(p_i1582_1_); - this.ignoreFrustumCheck = true; - startX = (int) posX; - startZ = (int) posZ; - targetX = (int) posX; - targetZ = (int) posZ; - } - - public boolean canBeCollidedWith() { - return true; - } - - public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) { - if(this.isEntityInvulnerable()) { - return false; - } else { - if(!this.isDead && !this.worldObj.isRemote) { - health -= p_70097_2_; - - if(this.health <= 0) { - this.setDead(); - this.killMissile(); - } - } - - return true; - } - } - - private void killMissile() { - ExplosionLarge.explode(worldObj, posX, posY, posZ, 5, true, false, true); - ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075); + public EntityMissileCustom(World world) { + super(world); } public EntityMissileCustom(World world, float x, float y, float z, int a, int b, MissileStruct template) { super(world); this.ignoreFrustumCheck = true; - /* - * this.posX = x; this.posY = y; this.posZ = z; - */ this.setLocationAndAngles(x, y, z, 0, 0); startX = (int) x; startZ = (int) z; targetX = a; targetZ = b; - this.motionY = 2; - - this.template = template; - - this.dataWatcher.updateObject(9, Item.getIdFromItem(template.warhead)); - this.dataWatcher.updateObject(10, Item.getIdFromItem(template.fuselage)); - if(template.fins != null) - this.dataWatcher.updateObject(11, Item.getIdFromItem(template.fins)); - else - this.dataWatcher.updateObject(11, Integer.valueOf(0)); - this.dataWatcher.updateObject(12, Item.getIdFromItem(template.thruster)); Vec3 vector = Vec3.createVectorHelper(targetX - startX, 0, targetZ - startZ); accelXZ = decelY = 1 / vector.lengthVector(); decelY *= 2; + velocity = 0; - velocity = 0.0; + this.dataWatcher.updateObject(9, Item.getIdFromItem(template.warhead)); + this.dataWatcher.updateObject(10, Item.getIdFromItem(template.fuselage)); + this.dataWatcher.updateObject(12, Item.getIdFromItem(template.thruster)); + if(template.fins != null) { + this.dataWatcher.updateObject(11, Item.getIdFromItem(template.fins)); + } else { + this.dataWatcher.updateObject(11, Integer.valueOf(0)); + } ItemMissile fuselage = (ItemMissile) template.fuselage; ItemMissile thruster = (ItemMissile) template.thruster; @@ -125,43 +69,24 @@ public class EntityMissileCustom extends Entity implements IChunkLoader, IRadarD } @Override - protected void entityInit() { - init(ForgeChunkManager.requestTicket(MainRegistry.instance, worldObj, Type.ENTITY)); - this.dataWatcher.addObject(8, Integer.valueOf(this.health)); - - if(template != null) { - this.dataWatcher.addObject(9, Integer.valueOf(Item.getIdFromItem(template.warhead))); - this.dataWatcher.addObject(10, Integer.valueOf(Item.getIdFromItem(template.fuselage))); - - if(template.fins != null) - this.dataWatcher.addObject(11, Integer.valueOf(Item.getIdFromItem(template.fins))); - else - this.dataWatcher.addObject(11, Integer.valueOf(0)); - - this.dataWatcher.addObject(12, Integer.valueOf(Item.getIdFromItem(template.thruster))); - } else { - this.dataWatcher.addObject(9, Integer.valueOf(0)); - this.dataWatcher.addObject(10, Integer.valueOf(0)); - this.dataWatcher.addObject(11, Integer.valueOf(0)); - this.dataWatcher.addObject(12, Integer.valueOf(0)); - } + protected void killMissile() { + ExplosionLarge.explode(worldObj, posX, posY, posZ, 5, true, false, true); + ExplosionLarge.spawnShrapnelShower(worldObj, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075); } @Override - protected void readEntityFromNBT(NBTTagCompound nbt) { - motionX = nbt.getDouble("moX"); - motionY = nbt.getDouble("moY"); - motionZ = nbt.getDouble("moZ"); - posX = nbt.getDouble("poX"); - posY = nbt.getDouble("poY"); - posZ = nbt.getDouble("poZ"); - decelY = nbt.getDouble("decel"); - accelXZ = nbt.getDouble("accel"); - targetX = nbt.getInteger("tX"); - targetZ = nbt.getInteger("tZ"); - startX = nbt.getInteger("sX"); - startZ = nbt.getInteger("sZ"); - velocity = nbt.getInteger("veloc"); + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(8, Integer.valueOf(this.health)); + this.dataWatcher.addObject(9, Integer.valueOf(0)); + this.dataWatcher.addObject(10, Integer.valueOf(0)); + this.dataWatcher.addObject(11, Integer.valueOf(0)); + this.dataWatcher.addObject(12, Integer.valueOf(0)); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); fuel = nbt.getFloat("fuel"); consumption = nbt.getFloat("consumption"); this.dataWatcher.updateObject(9, nbt.getInteger("warhead")); @@ -171,20 +96,8 @@ public class EntityMissileCustom extends Entity implements IChunkLoader, IRadarD } @Override - protected void writeEntityToNBT(NBTTagCompound nbt) { - nbt.setDouble("moX", motionX); - nbt.setDouble("moY", motionY); - nbt.setDouble("moZ", motionZ); - nbt.setDouble("poX", posX); - nbt.setDouble("poY", posY); - nbt.setDouble("poZ", posZ); - nbt.setDouble("decel", decelY); - nbt.setDouble("accel", accelXZ); - nbt.setInteger("tX", targetX); - nbt.setInteger("tZ", targetZ); - nbt.setInteger("sX", startX); - nbt.setInteger("sZ", startZ); - nbt.setDouble("veloc", velocity); + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); nbt.setFloat("fuel", fuel); nbt.setFloat("consumption", consumption); nbt.setInteger("warhead", this.dataWatcher.getWatchableObjectInt(9)); @@ -192,118 +105,28 @@ public class EntityMissileCustom extends Entity implements IChunkLoader, IRadarD nbt.setInteger("fins", this.dataWatcher.getWatchableObjectInt(11)); nbt.setInteger("thruster", this.dataWatcher.getWatchableObjectInt(12)); } + + @Override + protected void spawnContrail() { - protected void rotation() { - float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); - this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + Vec3 v = Vec3.createVectorHelper(motionX, motionY, motionZ).normalize(); + String smoke = ""; + ItemMissile part = (ItemMissile) Item.getItemById(this.dataWatcher.getWatchableObjectInt(10)); + FuelType type = (FuelType) part.attributes[0]; - for(this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI) - 90; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { - ; + switch(type) { + case BALEFIRE: smoke = "exBalefire"; break; + case HYDROGEN: smoke = "exHydrogen"; break; + case KEROSENE: smoke = "exKerosene"; break; + case SOLID: smoke = "exSolid"; break; + case XENON: break; } - while(this.rotationPitch - this.prevRotationPitch >= 180.0F) { - this.prevRotationPitch += 360.0F; - } - - while(this.rotationYaw - this.prevRotationYaw < -180.0F) { - this.prevRotationYaw -= 360.0F; - } - - while(this.rotationYaw - this.prevRotationYaw >= 180.0F) { - this.prevRotationYaw += 360.0F; - } + if(!smoke.isEmpty()) for(int i = 0; i < velocity; i++) MainRegistry.proxy.spawnParticle(posX - v.xCoord * i, posY - v.yCoord * i, posZ - v.zCoord * i, smoke, null); } @Override - public void onUpdate() { - this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); - - this.setLocationAndAngles(posX + this.motionX * velocity, posY + this.motionY * velocity, posZ + this.motionZ * velocity, 0, 0); - - this.rotation(); - - if(fuel > 0 || worldObj.isRemote) { - - fuel -= consumption; - - this.motionY -= decelY * velocity; - - Vec3 vector = Vec3.createVectorHelper(targetX - startX, 0, targetZ - startZ); - vector = vector.normalize(); - vector.xCoord *= accelXZ * velocity; - vector.zCoord *= accelXZ * velocity; - - if(motionY > 0) { - motionX += vector.xCoord; - motionZ += vector.zCoord; - } - - if(motionY < 0) { - motionX -= vector.xCoord; - motionZ -= vector.zCoord; - } - - if(velocity < 5) - velocity += 0.01; - } else { - - motionX *= 0.99; - motionZ *= 0.99; - - if(motionY > -1.5) - motionY -= 0.05; - } - - if(this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ) != Blocks.air && this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ) != Blocks.water && this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ) != Blocks.flowing_water) { - - if(!this.worldObj.isRemote) { - onImpact(); - } - this.setDead(); - return; - } - - if(this.worldObj.isRemote) { - - Vec3 v = Vec3.createVectorHelper(motionX, motionY, motionZ); - v = v.normalize(); - - String smoke = ""; - - ItemMissile part = (ItemMissile) Item.getItemById(this.dataWatcher.getWatchableObjectInt(10)); - FuelType type = (FuelType) part.attributes[0]; - - switch(type) { - case BALEFIRE: - smoke = "exBalefire"; - break; - case HYDROGEN: - smoke = "exHydrogen"; - break; - case KEROSENE: - smoke = "exKerosene"; - break; - case SOLID: - smoke = "exSolid"; - break; - case XENON: - break; - } - - for(int i = 0; i < velocity; i++) - MainRegistry.proxy.spawnParticle(posX - v.xCoord * i, posY - v.yCoord * i, posZ - v.zCoord * i, smoke, null); - } - - loadNeighboringChunks((int) (posX / 16), (int) (posZ / 16)); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean isInRangeToRenderDist(double distance) { - return distance < 2500000; - } - - public void onImpact() { + public void onImpact() { //TODO: demolish this steaming pile of shit ItemMissile part = (ItemMissile) Item.getItemById(this.dataWatcher.getWatchableObjectInt(9)); @@ -378,67 +201,22 @@ public class EntityMissileCustom extends Entity implements IChunkLoader, IRadarD } } - public void init(Ticket ticket) { - if(!worldObj.isRemote) { - - if(ticket != null) { - - if(loaderTicket == null) { - - loaderTicket = ticket; - loaderTicket.bindEntity(this); - loaderTicket.getModData(); - } - - ForgeChunkManager.forceChunk(loaderTicket, new ChunkCoordIntPair(chunkCoordX, chunkCoordZ)); - } - } - } - - List loadedChunks = new ArrayList(); - - public void loadNeighboringChunks(int newChunkX, int newChunkZ) { - if(!worldObj.isRemote && loaderTicket != null) { - for(ChunkCoordIntPair chunk : loadedChunks) { - ForgeChunkManager.unforceChunk(loaderTicket, chunk); - } - - loadedChunks.clear(); - loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ + 1)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ - 1)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ - 1)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ + 1)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX + 1, newChunkZ)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ + 1)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX - 1, newChunkZ)); - loadedChunks.add(new ChunkCoordIntPair(newChunkX, newChunkZ - 1)); - - for(ChunkCoordIntPair chunk : loadedChunks) { - ForgeChunkManager.forceChunk(loaderTicket, chunk); - } - } - } - @Override public RadarTargetType getTargetType() { ItemMissile part = (ItemMissile) Item.getItemById(this.dataWatcher.getWatchableObjectInt(10)); - PartSize top = part.top; PartSize bottom = part.bottom; - if(top == PartSize.SIZE_10 && bottom == PartSize.SIZE_10) - return RadarTargetType.MISSILE_10; - if(top == PartSize.SIZE_10 && bottom == PartSize.SIZE_15) - return RadarTargetType.MISSILE_10_15; - if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) - return RadarTargetType.MISSILE_15; - if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) - return RadarTargetType.MISSILE_15_20; - if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) - return RadarTargetType.MISSILE_20; + if(top == PartSize.SIZE_10 && bottom == PartSize.SIZE_10) return RadarTargetType.MISSILE_10; + if(top == PartSize.SIZE_10 && bottom == PartSize.SIZE_15) return RadarTargetType.MISSILE_10_15; + if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_15) return RadarTargetType.MISSILE_15; + if(top == PartSize.SIZE_15 && bottom == PartSize.SIZE_20) return RadarTargetType.MISSILE_15_20; + if(top == PartSize.SIZE_20 && bottom == PartSize.SIZE_20) return RadarTargetType.MISSILE_20; return RadarTargetType.PLAYER; } + + @Override public List getDebris() { return new ArrayList(); } + @Override public ItemStack getDebrisRareDrop() { return null; } } diff --git a/src/main/resources/assets/hbm/textures/items/coal_eternal.png b/src/main/resources/assets/hbm/textures/items/coal_eternal.png new file mode 100644 index 0000000000000000000000000000000000000000..36ee856f8fe79f1c521ddfa5f78471460016cc3d GIT binary patch literal 429 zcmV;e0aE^nP)@>LIOiaEXe{I>ayJlzFi;Og@3kZ XnbD=?!6j$g00000NkvXXu0mjfLW;XH literal 0 HcmV?d00001