From 30e2a13f62e6b319cf95b2e7b1608f1006baa1b6 Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 10 Aug 2023 15:18:54 +0200 Subject: [PATCH] fixing mojank spaghetti episode 58304 --- .../entity/projectile/EntityBulletBaseNT.java | 17 +++---- .../entity/projectile/EntityThrowableNT.java | 29 ++++++++---- .../hbm/handler/BulletConfigSyncingUtil.java | 2 + .../handler/guncfg/BulletConfigFactory.java | 13 ++++-- .../hbm/handler/guncfg/Gun20GaugeFactory.java | 1 + .../handler/guncfg/Gun44MagnumFactory.java | 2 +- .../hbm/handler/guncfg/Gun4GaugeFactory.java | 6 +-- .../hbm/handler/guncfg/Gun50BMGFactory.java | 13 ++++-- .../hbm/handler/guncfg/Gun556mmFactory.java | 9 ++-- .../hbm/handler/guncfg/Gun75BoltFactory.java | 2 +- .../hbm/handler/guncfg/GunCannonFactory.java | 2 +- .../handler/guncfg/GunDetonatorFactory.java | 2 +- .../hbm/handler/guncfg/GunEnergyFactory.java | 10 ++-- .../hbm/handler/guncfg/GunFatmanFactory.java | 16 +++---- .../hbm/handler/guncfg/GunGrenadeFactory.java | 18 ++++++- .../com/hbm/handler/guncfg/GunNPCFactory.java | 6 +-- .../hbm/handler/guncfg/GunOSIPRFactory.java | 2 +- .../hbm/handler/guncfg/GunRocketFactory.java | 4 +- .../java/com/hbm/items/ItemAmmoEnums.java | 3 +- .../java/com/hbm/items/weapon/ItemAmmo.java | 1 + .../com/hbm/items/weapon/ItemAmmoArty.java | 2 +- src/main/java/com/hbm/util/TrackerUtil.java | 44 ++++++++++++++++++ .../items/ammo_grenade_leadburster.png | Bin 0 -> 291 bytes 23 files changed, 147 insertions(+), 57 deletions(-) create mode 100644 src/main/java/com/hbm/util/TrackerUtil.java create mode 100644 src/main/resources/assets/hbm/textures/items/ammo_grenade_leadburster.png diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseNT.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseNT.java index 65741dbd4..a1a3a0961 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBaseNT.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBaseNT.java @@ -166,6 +166,7 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet @Override protected void entityInit() { + super.entityInit(); //style this.dataWatcher.addObject(16, Byte.valueOf((byte) 0)); //trail @@ -251,11 +252,11 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet if(mop.typeOfHit == mop.typeOfHit.BLOCK) { boolean hRic = rand.nextInt(100) < config.HBRC; - boolean doesRic = config.doesRicochet || hRic; + boolean doesRic = config.doesRicochet && hRic; if(!config.isSpectral && !doesRic) { this.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); - this.onBlockImpact(mop.blockX, mop.blockY, mop.blockZ); + this.onBlockImpact(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit); } if(doesRic) { @@ -302,7 +303,7 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet } else { if(!worldObj.isRemote) { this.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); - onBlockImpact(mop.blockX, mop.blockY, mop.blockZ); + onBlockImpact(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit); } } @@ -375,13 +376,13 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet } //for when a bullet dies by hitting a block - private void onBlockImpact(int bX, int bY, int bZ) { + private void onBlockImpact(int bX, int bY, int bZ, int sideHit) { if(config.bntImpact != null) - config.bntImpact.behaveBlockHit(this, bX, bY, bZ); + config.bntImpact.behaveBlockHit(this, bX, bY, bZ, sideHit); if(!worldObj.isRemote) { - if(!config.liveAfterImpact && !config.isSpectral && bY > -1) this.setDead(); + if(!config.liveAfterImpact && !config.isSpectral && bY > -1 && !this.inGround) this.setDead(); if(!config.doesPenetrate && bY == -1) this.setDead(); } @@ -472,7 +473,7 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet //for when a bullet dies by hitting an entity private void onEntityImpact(Entity e) { onEntityHurt(e); - onBlockImpact(-1, -1, -1); + onBlockImpact(-1, -1, -1, -1); if(config.bntHit != null) config.bntHit.behaveEntityHit(this, e); @@ -582,6 +583,6 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet public static interface IBulletHurtBehaviorNT { public void behaveEntityHurt(EntityBulletBaseNT bullet, Entity hit); } public static interface IBulletHitBehaviorNT { public void behaveEntityHit(EntityBulletBaseNT bullet, Entity hit); } public static interface IBulletRicochetBehaviorNT { public void behaveBlockRicochet(EntityBulletBaseNT bullet, int x, int y, int z); } - public static interface IBulletImpactBehaviorNT { public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z); } + public static interface IBulletImpactBehaviorNT { public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit); } public static interface IBulletUpdateBehaviorNT { public void behaveUpdate(EntityBulletBaseNT bullet); } } diff --git a/src/main/java/com/hbm/entity/projectile/EntityThrowableNT.java b/src/main/java/com/hbm/entity/projectile/EntityThrowableNT.java index fbd99c23c..892e59e79 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityThrowableNT.java +++ b/src/main/java/com/hbm/entity/projectile/EntityThrowableNT.java @@ -2,6 +2,8 @@ package com.hbm.entity.projectile; import java.util.List; +import com.hbm.util.TrackerUtil; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -32,7 +34,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { public int throwableShake; protected EntityLivingBase thrower; private String throwerName; - private int ticksInGround; + public int ticksInGround; private int ticksInAir; public EntityThrowableNT(World world) { @@ -41,7 +43,17 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { } @Override - protected void entityInit() { } + protected void entityInit() { + this.dataWatcher.addObject(2, Byte.valueOf((byte)0)); + } + + public void setStuckIn(int side) { + this.dataWatcher.updateObject(2, (byte) side); + } + + public int getStuckIn() { + return this.dataWatcher.getWatchableObjectByte(2); + } @Override @SideOnly(Side.CLIENT) @@ -214,10 +226,6 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { } } - this.posX += this.motionX * motionMult(); - this.posY += this.motionY * motionMult(); - this.posZ += this.motionZ * motionMult(); - if(mop != null) { if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) == Blocks.portal) { this.setInPortal(); @@ -250,6 +258,10 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { float drag = this.getAirDrag(); double gravity = this.getGravityVelocity(); + this.posX += this.motionX * motionMult(); + this.posY += this.motionY * motionMult(); + this.posZ += this.motionZ * motionMult(); + if(this.isInWater()) { for(int i = 0; i < 4; ++i) { float f = 0.25F; @@ -264,7 +276,6 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { this.motionZ *= (double) drag; this.motionY -= gravity; this.setPosition(this.posX, this.posY, this.posZ); - } } @@ -280,7 +291,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { return 5; } - public void getStuck(int x, int y, int z) { + public void getStuck(int x, int y, int z, int side) { this.stuckBlockX = x; this.stuckBlockY = y; this.stuckBlockZ = z; @@ -289,6 +300,8 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile { this.motionX = 0; this.motionY = 0; this.motionZ = 0; + this.setStuckIn(side); + TrackerUtil.sendTeleport(worldObj, this); } public double getGravityVelocity() { diff --git a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java index 19987ab65..3c2c2e7a3 100644 --- a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java +++ b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java @@ -68,6 +68,7 @@ public class BulletConfigSyncingUtil { public static int GRENADE_PHOSPHORUS = i++; public static int GRENADE_TRACER = i++; public static int GRENADE_KAMPF = i++; + public static int GRENADE_LEADBURSTER = i++; public static int G12_NORMAL = i++; public static int G12_INCENDIARY = i++; @@ -365,6 +366,7 @@ public class BulletConfigSyncingUtil { configSet.put(GRENADE_NUCLEAR, GunGrenadeFactory.getGrenadeNuclearConfig()); configSet.put(GRENADE_TRACER, GunGrenadeFactory.getGrenadeTracerConfig()); configSet.put(GRENADE_KAMPF, GunGrenadeFactory.getGrenadeKampfConfig()); + configSet.put(GRENADE_LEADBURSTER, GunGrenadeFactory.getGrenadeLeadbursterConfig()); configSet.put(G12_NORMAL, Gun12GaugeFactory.get12GaugeConfig()); configSet.put(G12_INCENDIARY, Gun12GaugeFactory.get12GaugeFireConfig()); diff --git a/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java b/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java index 01549a613..c4672568d 100644 --- a/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java @@ -146,7 +146,7 @@ public class BulletConfigFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(bullet.worldObj.isRemote) return; @@ -310,12 +310,19 @@ public class BulletConfigFactory { } } + public static void makeFlechette(BulletConfiguration bullet) { + + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { + bulletnt.getStuck(x, y, z, sideHit); + }; + } + public static IBulletImpactBehaviorNT getPhosphorousEffect(final int radius, final int duration, final int count, final double motion, float hazeChance) { IBulletImpactBehaviorNT impact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { List hit = bullet.worldObj.getEntitiesWithinAABBExcludingEntity(bullet, AxisAlignedBB.getBoundingBox(bullet.posX - radius, bullet.posY - radius, bullet.posZ - radius, bullet.posX + radius, bullet.posY + radius, bullet.posZ + radius)); @@ -357,7 +364,7 @@ public class BulletConfigFactory { IBulletImpactBehaviorNT impact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { List hit = bullet.worldObj.getEntitiesWithinAABBExcludingEntity(bullet, AxisAlignedBB.getBoundingBox(bullet.posX - radius, bullet.posY - radius, bullet.posZ - radius, bullet.posX + radius, bullet.posY + radius, bullet.posZ + radius)); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java index a985bf636..755296329 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java @@ -147,6 +147,7 @@ public class Gun20GaugeFactory { bullet.style = BulletConfiguration.STYLE_FLECHETTE; bullet.HBRC = 2; bullet.LBRC = 95; + BulletConfigFactory.makeFlechette(bullet); bullet.spentCasing = CASING20GAUGE.clone().register("20GaFlech").setColor(0x2847FF, SpentCasing.COLOR_CASE_BRASS); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java index a0dff1be2..515b1b8bf 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java @@ -223,7 +223,7 @@ public class Gun44MagnumFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java index 191c0eb93..9760fb083 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java @@ -205,7 +205,7 @@ public class Gun4GaugeFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); @@ -251,7 +251,7 @@ public class Gun4GaugeFactory { bullet.trail = 1; bullet.explosive = 0.0F; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; @@ -283,7 +283,7 @@ public class Gun4GaugeFactory { bullet.trail = 1; bullet.explosive = 0.0F; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index beda66771..f9e0a191b 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -62,7 +62,7 @@ public class Gun50BMGFactory { bullet.leadChance = 20; bullet.blockDamage = false; - bullet.bntImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 2.0F, false, false); + bullet.bntImpact = (projectile, x, y, z, sideHit) -> projectile.worldObj.newExplosion(projectile, x, y, z, 2.0F, false, false); bullet.spentCasing = CASINGLUNA.clone().register("LunaStock"); @@ -76,7 +76,7 @@ public class Gun50BMGFactory { bullet.ammo.meta = 1; bullet.incendiary = 10; - bullet.bntImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 5.0F, true, false); + bullet.bntImpact = (projectile, x, y, z, sideHit) -> projectile.worldObj.newExplosion(projectile, x, y, z, 5.0F, true, false); bullet.spentCasing = CASINGLUNA.clone().register("LunaInc"); @@ -91,7 +91,7 @@ public class Gun50BMGFactory { bullet.ammo.meta = 2; bullet.explosive = 25; bullet.destroysBlocks = true; - bullet.bntImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 25.0F, true, false); + bullet.bntImpact = (projectile, x, y, z, sideHit) -> projectile.worldObj.newExplosion(projectile, x, y, z, 25.0F, true, false); bullet.spentCasing = CASINGLUNA.clone().register("LunaExp"); @@ -264,7 +264,7 @@ public class Gun50BMGFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); @@ -368,7 +368,7 @@ public class Gun50BMGFactory { bulletnt.worldObj.spawnEntityInWorld(meteor); }; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; @@ -397,6 +397,7 @@ public class Gun50BMGFactory { bullet.dmgMin = 50; bullet.dmgMax = 54; bullet.style = bullet.STYLE_FLECHETTE; + BulletConfigFactory.makeFlechette(bullet); bullet.spentCasing = CASING50BMG.clone().register("50BMGFlech"); @@ -412,6 +413,7 @@ public class Gun50BMGFactory { bullet.dmgMin = 60; bullet.dmgMax = 64; bullet.style = bullet.STYLE_FLECHETTE; + BulletConfigFactory.makeFlechette(bullet); bullet.bntHit = (bulletnt, hit) -> { @@ -437,6 +439,7 @@ public class Gun50BMGFactory { bullet.dmgMin = 60; bullet.dmgMax = 64; bullet.style = bullet.STYLE_FLECHETTE; + BulletConfigFactory.makeFlechette(bullet); bullet.bntHit = (bulletnt, hit) -> { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java index d983998e8..fafa0b642 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -182,7 +182,7 @@ public class Gun556mmFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); @@ -266,7 +266,7 @@ public class Gun556mmFactory { bulletnt.worldObj.spawnEntityInWorld(meteor); }; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; @@ -322,6 +322,7 @@ public class Gun556mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_556.stackFromEnum(Ammo556mm.FLECHETTE_INCENDIARY)); bullet.incendiary = 5; + BulletConfigFactory.makeFlechette(bullet); bullet.spentCasing = CASING556.clone().register("556FlecInc"); @@ -340,7 +341,7 @@ public class Gun556mmFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); @@ -395,7 +396,7 @@ public class Gun556mmFactory { bulletnt.worldObj.spawnEntityInWorld(meteor); }; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java index b3d9bae6f..cc05924f6 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun75BoltFactory.java @@ -134,7 +134,7 @@ public class Gun75BoltFactory { bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { NBTTagCompound data = new NBTTagCompound(); data.setString("type", "vanillaburst"); diff --git a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java index 2d8710522..411574bbe 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java @@ -84,7 +84,7 @@ public class GunCannonFactory { bullet.dmgMin = 100; bullet.dmgMax = 150; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { BulletConfigFactory.nuclearExplosion(bulletnt, x, y, z, ExplosionNukeSmall.PARAMS_TOTS); }; diff --git a/src/main/java/com/hbm/handler/guncfg/GunDetonatorFactory.java b/src/main/java/com/hbm/handler/guncfg/GunDetonatorFactory.java index ab25f43bc..093a3d90b 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunDetonatorFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunDetonatorFactory.java @@ -88,7 +88,7 @@ public class GunDetonatorFactory { bullet.doesRicochet = false; bullet.setToBolt(BulletConfiguration.BOLT_LASER); - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { World world = bulletnt.worldObj; if(!world.isRemote && y > 0) { diff --git a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java index 1e7d4342d..0ea31f450 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java @@ -431,7 +431,7 @@ public class GunEnergyFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { NBTTagCompound data = new NBTTagCompound(); @@ -554,7 +554,7 @@ public class GunEnergyFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { @@ -632,7 +632,7 @@ public class GunEnergyFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { @@ -721,7 +721,7 @@ public class GunEnergyFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { @@ -812,7 +812,7 @@ public class GunEnergyFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { ExplosionChaos.explodeZOMG(bullet.worldObj, (int)Math.floor(bullet.posX), (int)Math.floor(bullet.posY), (int)Math.floor(bullet.posZ), 5); diff --git a/src/main/java/com/hbm/handler/guncfg/GunFatmanFactory.java b/src/main/java/com/hbm/handler/guncfg/GunFatmanFactory.java index e068b15f4..5ed0b21db 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunFatmanFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunFatmanFactory.java @@ -135,7 +135,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { BulletConfigFactory.nuclearExplosion(bullet, x, y, z, ExplosionNukeSmall.PARAMS_MEDIUM); } }; @@ -151,7 +151,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { BulletConfigFactory.nuclearExplosion(bullet, x, y, z, ExplosionNukeSmall.PARAMS_LOW); } }; @@ -167,7 +167,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { BulletConfigFactory.nuclearExplosion(bullet, x, y, z, ExplosionNukeSmall.PARAMS_HIGH); } }; @@ -187,7 +187,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { BulletConfigFactory.nuclearExplosion(bullet, x, y, z, ExplosionNukeSmall.PARAMS_TOTS); } }; @@ -203,7 +203,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { BulletConfigFactory.nuclearExplosion(bullet, x, y, z, ExplosionNukeSmall.PARAMS_SAFE); } }; @@ -220,7 +220,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { @@ -252,7 +252,7 @@ public class GunFatmanFactory { bullet.bntImpact = new IBulletImpactBehaviorNT() { @Override - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { @@ -503,7 +503,7 @@ public class GunFatmanFactory { bullet.style = BulletConfiguration.STYLE_BF; bullet.bntImpact = new IBulletImpactBehaviorNT() { - public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z) { + @Override public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) { if(!bullet.worldObj.isRemote) { diff --git a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java index d65f964e9..2d31dca38 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java @@ -60,6 +60,7 @@ public class GunGrenadeFactory { config.config.add(BulletConfigSyncingUtil.GRENADE_NUCLEAR); config.config.add(BulletConfigSyncingUtil.GRENADE_TRACER); config.config.add(BulletConfigSyncingUtil.GRENADE_KAMPF); + config.config.add(BulletConfigSyncingUtil.GRENADE_LEADBURSTER); config.durability = 300; config.ejector = EJECTOR_LAUNCHER; @@ -211,7 +212,7 @@ public class GunGrenadeFactory { bullet.velocity = 4; bullet.explosive = 0.0F; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { BulletConfigFactory.nuclearExplosion(bulletnt, x, y, z, ExplosionNukeSmall.PARAMS_TOTS); }; @@ -253,4 +254,19 @@ public class GunGrenadeFactory { return bullet; } + + public static BulletConfiguration getGrenadeLeadbursterConfig() { + + BulletConfiguration bullet = BulletConfigFactory.standardRocketConfig(); + + bullet.ammo = new ComparableStack(ModItems.ammo_grenade.stackFromEnum(AmmoGrenade.LEADBURSTER)); + bullet.spread = 0.0F; + bullet.gravity = 0.01D; + bullet.explosive = 0F; + bullet.style = BulletConfiguration.STYLE_APDS; + bullet.doesRicochet = false; + BulletConfigFactory.makeFlechette(bullet); + + return bullet; + } } diff --git a/src/main/java/com/hbm/handler/guncfg/GunNPCFactory.java b/src/main/java/com/hbm/handler/guncfg/GunNPCFactory.java index 8a6bffe40..d7fff5e2b 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunNPCFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunNPCFactory.java @@ -124,7 +124,7 @@ public class GunNPCFactory { bullet.vPFX = "reddust"; bullet.damageType = ModDamageSource.s_laser; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; @@ -252,7 +252,7 @@ public class GunNPCFactory { if(target != null) { if(bullet.getDistanceSqToEntity(target) < 5) { - bullet.getConfig().bntImpact.behaveBlockHit(bullet, -1, -1, -1); + bullet.getConfig().bntImpact.behaveBlockHit(bullet, -1, -1, -1, -1); bullet.setDead(); return; } @@ -306,7 +306,7 @@ public class GunNPCFactory { } }; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { bulletnt.worldObj.playSoundEffect(bulletnt.posX, bulletnt.posY, bulletnt.posZ, "hbm:entity.ufoBlast", 5.0F, 0.9F + bulletnt.worldObj.rand.nextFloat() * 0.2F); bulletnt.worldObj.playSoundEffect(bulletnt.posX, bulletnt.posY, bulletnt.posZ, "fireworks.blast", 5.0F, 0.5F); diff --git a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java index 720a57e2c..47c3e698c 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java @@ -127,7 +127,7 @@ public class GunOSIPRFactory { }; - bullet.bntImpact = (ball, x, y, z) -> { + bullet.bntImpact = (ball, x, y, z, sideHit) -> { final Block block = ball.worldObj.getBlock(x, y, z); if(block instanceof RedBarrel) ((RedBarrel) block).explode(ball.worldObj, x, y, z); diff --git a/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java b/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java index cea0490c3..b6b0714dd 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunRocketFactory.java @@ -284,7 +284,7 @@ public class GunRocketFactory { bullet.incendiary = 0; bullet.trail = 7; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { BulletConfigFactory.nuclearExplosion(bulletnt, x, y, z, ExplosionNukeSmall.PARAMS_MEDIUM); }; @@ -395,7 +395,7 @@ public class GunRocketFactory { bullet.incendiary = 0; bullet.trail = 7; - bullet.bntImpact = (bulletnt, x, y, z) -> { + bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> { if(bulletnt.worldObj.isRemote) return; diff --git a/src/main/java/com/hbm/items/ItemAmmoEnums.java b/src/main/java/com/hbm/items/ItemAmmoEnums.java index 8ef0638d7..54ad9f1c6 100644 --- a/src/main/java/com/hbm/items/ItemAmmoEnums.java +++ b/src/main/java/com/hbm/items/ItemAmmoEnums.java @@ -186,7 +186,8 @@ public class ItemAmmoEnums { FINNED("ammo_grenade_finned", AmmoItemTrait.PRO_GRAVITY, AmmoItemTrait.CON_RADIUS), NUCLEAR("ammo_grenade_nuclear", AmmoItemTrait.PRO_NUCLEAR, AmmoItemTrait.PRO_RANGE, AmmoItemTrait.CON_HEAVY_WEAR), TRACER("ammo_grenade_tracer", AmmoItemTrait.NEU_BLANK), - KAMPF("ammo_grenade_kampf", AmmoItemTrait.PRO_ROCKET_PROPELLED, AmmoItemTrait.PRO_RADIUS, AmmoItemTrait.PRO_ACCURATE1, AmmoItemTrait.CON_WEAR); + KAMPF("ammo_grenade_kampf", AmmoItemTrait.PRO_ROCKET_PROPELLED, AmmoItemTrait.PRO_RADIUS, AmmoItemTrait.PRO_ACCURATE1, AmmoItemTrait.CON_WEAR), + LEADBURSTER("ammo_grenade_leadburster", AmmoItemTrait.NEU_LEADBURSTER, AmmoItemTrait.CON_NO_EXPLODE1); private final Set traits; private final String unloc; diff --git a/src/main/java/com/hbm/items/weapon/ItemAmmo.java b/src/main/java/com/hbm/items/weapon/ItemAmmo.java index f83ea596c..eebc241a8 100644 --- a/src/main/java/com/hbm/items/weapon/ItemAmmo.java +++ b/src/main/java/com/hbm/items/weapon/ItemAmmo.java @@ -65,6 +65,7 @@ public class ItemAmmo extends ItemEnumMulti { NEU_STARMETAL, NEU_TRACER, NEU_UHH, + NEU_LEADBURSTER, NEU_WARCRIME1, NEU_WARCRIME2, PRO_ACCURATE1, diff --git a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java index d4d263fa5..bb62a11b5 100644 --- a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java +++ b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java @@ -305,7 +305,7 @@ public class ItemAmmoArty extends Item { this.itemTypes[CARGO] = new ArtilleryShell("ammo_arty_cargo", SpentCasing.COLOR_CASE_16INCH) { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { if(mop.typeOfHit == MovingObjectType.BLOCK) { shell.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); - shell.getStuck(mop.blockX, mop.blockY, mop.blockZ); + shell.getStuck(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit); } }}; diff --git a/src/main/java/com/hbm/util/TrackerUtil.java b/src/main/java/com/hbm/util/TrackerUtil.java new file mode 100644 index 000000000..9889d0c6e --- /dev/null +++ b/src/main/java/com/hbm/util/TrackerUtil.java @@ -0,0 +1,44 @@ +package com.hbm.util; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityTracker; +import net.minecraft.entity.EntityTrackerEntry; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +/** + * This absolute fucking mess of a class is the direct consequence of mojank's terrible entity tracker that allows for 0 flexibility with how entities are synced. + * + * @author hbm + */ +public class TrackerUtil { + + /** Grabs the tracker entry from the given entity */ + public static EntityTrackerEntry getTrackerEntry(WorldServer world, int entityId) { + EntityTracker entitytracker = world.getEntityTracker(); + IntHashMap map = ReflectionHelper.getPrivateValue(EntityTracker.class, entitytracker, "trackedEntityIDs", "field_72794_c"); + EntityTrackerEntry entry = (EntityTrackerEntry) map.lookup(entityId); + return entry; + } + + /** Force-teleports the given entity using the tracker, resetting the tick count to 0 to prevent movement during this tick */ + public static void sendTeleport(World world, Entity e) { + + if(world instanceof WorldServer) { + WorldServer server = (WorldServer) world; + EntityTrackerEntry entry = getTrackerEntry(server, e.getEntityId()); + int xScaled = e.myEntitySize.multiplyBy32AndRound(e.posX); + int yScaled = MathHelper.floor_double(e.posY * 32.0D); + int zScaled = e.myEntitySize.multiplyBy32AndRound(e.posZ); + int yaw = MathHelper.floor_float(e.rotationYaw * 256.0F / 360.0F); + int pitch = MathHelper.floor_float(e.rotationPitch * 256.0F / 360.0F); + entry.func_151259_a(new S18PacketEntityTeleport(e.getEntityId(), xScaled, yScaled, zScaled, (byte)yaw, (byte)pitch)); + //this prevents the tracker from sending movement updates in the same tick + entry.ticks = 0; + } + } +} diff --git a/src/main/resources/assets/hbm/textures/items/ammo_grenade_leadburster.png b/src/main/resources/assets/hbm/textures/items/ammo_grenade_leadburster.png new file mode 100644 index 0000000000000000000000000000000000000000..dd2737ccb2bea3565b4261ce3e531e47394a1a8f GIT binary patch literal 291 zcmV+;0o?wHP)Vy(qmOG@bkd<)2$=NVO{s;bM7 z0wATtvMc}?V{SnTfMFQS9x{$2ecxY#Y$qHcBC<)>*n^%utk zJf6@whpHkXh{$gXyar@Qj#ZVWY3>2`!_GMX+O}Q2_fLji`fc#=C8dO_K6&xy23ax2 p&6DF6x8%KF>$?6Nko7MRfFH!Cb%!?pgY5tS002ovPDHLkV1k~{c69&% literal 0 HcmV?d00001