This commit is contained in:
Boblet 2024-10-29 16:49:26 +01:00
parent a37dd9e639
commit 4684058634
15 changed files with 97 additions and 67 deletions

View File

@ -25,11 +25,11 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.ForgeDirection;
public class BulletConfig {
public class BulletConfig implements Cloneable {
public static List<BulletConfig> configs = new ArrayList();
public final int id;
public int id;
public ComparableStack ammo;
/** How much ammo is added to a standard mag when loading one item */
@ -76,6 +76,13 @@ public class BulletConfig {
this.id = configs.size();
configs.add(this);
}
/** Required for the clone() operation to reset the ID, otherwise the ID and config entry will be the same as the original */
public BulletConfig forceReRegister() {
this.id = configs.size();
configs.add(this);
return this;
}
public BulletConfig setItem(Item ammo) { this.ammo = new ComparableStack(ammo); return this; }
public BulletConfig setItem(EnumAmmo ammo) { this.ammo = new ComparableStack(ModItems.ammo_standard, 1, ammo.ordinal()); return this; }
@ -193,4 +200,14 @@ public class BulletConfig {
}
}
};
@Override
public BulletConfig clone() {
try {
BulletConfig clone = (BulletConfig) super.clone();
clone.forceReRegister();
return clone;
} catch(CloneNotSupportedException e) { }
return null;
}
}

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import com.hbm.handler.CasingEjector;
import com.hbm.handler.HbmKeybinds.EnumKeybind;
import com.hbm.interfaces.IItemHUD;
import com.hbm.items.IEquipReceiver;
@ -14,7 +13,6 @@ import com.hbm.items.weapon.sedna.mags.IMagazine;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.packet.toclient.GunAnimationPacket;
import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.render.util.RenderScreenOverlay;
@ -22,7 +20,6 @@ import com.hbm.sound.AudioWrapper;
import com.hbm.util.BobMathUtil;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
@ -97,7 +94,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
A_SIDE,
B_SIDE,
LEGENDARY,
SEPCIAL,
SPECIAL,
SECRET,
DEBUG
}
@ -128,7 +125,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
case A_SIDE: list.add(EnumChatFormatting.YELLOW + "Standard Arsenal"); break;
case B_SIDE: list.add(EnumChatFormatting.GOLD + "B-Side"); break;
case LEGENDARY: list.add(EnumChatFormatting.RED + "Legendary Weapon"); break;
case SEPCIAL: list.add(EnumChatFormatting.AQUA + "Special Weapon"); break;
case SPECIAL: list.add(EnumChatFormatting.AQUA + "Special Weapon"); break;
case SECRET: list.add(EnumChatFormatting.DARK_RED + "SECRET"); break;
case DEBUG: list.add((BobMathUtil.getBlink() ? EnumChatFormatting.YELLOW : EnumChatFormatting.GOLD) + "DEBUG"); break;
}
@ -244,22 +241,6 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
if(timer <= 1) configs[i].getDecider(stack).accept(stack, ctx[i]);
}
}
public static void trySpawnCasing(Entity entity, CasingEjector ejector, BulletConfig bullet, ItemStack stack) {
if(ejector == null) return; //abort if the gun can't eject bullets at all
if(bullet == null) return; //abort if there's no valid bullet cfg
if(bullet.casing == null) return; //abort if the bullet is caseless
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "casing");
data.setFloat("pitch", (float) Math.toRadians(entity.rotationPitch));
data.setFloat("yaw", (float) Math.toRadians(entity.rotationYaw));
data.setBoolean("crouched", entity.isSneaking());
data.setString("name", bullet.casing.getName());
data.setInteger("ej", ejector.getId());
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ), new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 50));
}
// GUN DRAWN //
public static boolean getIsDrawn(ItemStack stack) { return getValueBool(stack, KEY_DRAWN); }

View File

@ -73,8 +73,9 @@ public class GunFactory {
R762_SP, R762_FMJ, R762_JHP, R762_AP, R762_DU,
BMG50_SP, BMG50_FMJ, BMG50_JHP, BMG50_AP, BMG50_DU,
G12_BP, G12_BP_MAGNUM, G12_BP_SLUG, G12, G12_SLUG, G12_FLECHETTE, G12_MAGNUM, G12_EXPLOSIVE, G12_PHOSPHORUS, G12_ANTHRAX,
G40_FLARE, G40,
ROCKET_HE, ROCKET_HEAT,
G40_FLARE,
G40_HE, G40_HEAT, G40_DEMO, G40_INC, G40_PHOSPHORUS,
ROCKET_HE, ROCKET_HEAT, ROCKET_DEMO, ROCKET_INC, ROCKET_PHOSPHORUS,
FLAME_DIESEL, FLAME_GAS, FLAME_NAPALM, FLAME_BALEFIRE,
M44_EQUESTRIAN, G12_EQUESTRIAN, BMG50_EQUESTRIAN
}

View File

@ -13,7 +13,11 @@ import static com.hbm.items.weapon.sedna.factory.XFactory9mm.*;
import static com.hbm.items.weapon.sedna.factory.XFactoryBlackPowder.*;
import static com.hbm.items.weapon.sedna.factory.XFactoryRocket.*;
import java.util.function.BiConsumer;
import com.hbm.entity.projectile.EntityBulletBaseMK4;
import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.BulletConfig;
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.weapon.sedna.*;
@ -57,25 +61,52 @@ public class GunFactoryClient {
//PROJECTILES
ammo_debug.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
ammo_debug_buckshot.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
stone.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
flint.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
iron.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
shot.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m357_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m357_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m357_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m357_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
m357_express.setRenderer(LegoClient.RENDER_EXPRESS_BULLET);
m44_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m44_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m44_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
m44_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
m44_express.setRenderer(LegoClient.RENDER_EXPRESS_BULLET);
m44_equestrian.setRenderer(LegoClient.RENDER_LEGENDARY_BULLET);
p22_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
p9_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p9_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p9_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p9_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
r556_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
r762_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
r762_du.setRenderer(LegoClient.RENDER_DU_BULLET);
bmg50_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
bmg50_du.setRenderer(LegoClient.RENDER_DU_BULLET);
g12_bp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
g12_bp_magnum.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
g12_bp_slug.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
@ -87,32 +118,17 @@ public class GunFactoryClient {
g12_phosphorus.setRenderer(LegoClient.RENDER_AP_BULLET);
g12_anthrax.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
g12_equestrian.setRenderer(LegoClient.RENDER_LEGENDARY_BULLET);
r762_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r762_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
r762_du.setRenderer(LegoClient.RENDER_DU_BULLET);
p22_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
p22_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
g40_flare.setRenderer(LegoClient.RENDER_FLARE);
g40.setRenderer(LegoClient.RENDER_GRENADE);
rocket_rpzb_he.setRenderer(LegoClient.RENDER_RPZB);
rocket_rpzb_heat.setRenderer(LegoClient.RENDER_RPZB);
rocket_qd_he.setRenderer(LegoClient.RENDER_QD);
rocket_qd_heat.setRenderer(LegoClient.RENDER_QD);
rocket_ml_he.setRenderer(LegoClient.RENDER_ML);
rocket_ml_heat.setRenderer(LegoClient.RENDER_ML);
r556_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
r556_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
bmg50_sp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_fmj.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_jhp.setRenderer(LegoClient.RENDER_STANDARD_BULLET);
bmg50_ap.setRenderer(LegoClient.RENDER_AP_BULLET);
bmg50_du.setRenderer(LegoClient.RENDER_DU_BULLET);
setRendererBulk(LegoClient.RENDER_GRENADE,
g40_he);
setRendererBulk(LegoClient.RENDER_RPZB,
rocket_rpzb_he, rocket_rpzb_heat);
setRendererBulk(LegoClient.RENDER_QD,
rocket_qd_he, rocket_qd_heat);
setRendererBulk(LegoClient.RENDER_ML,
rocket_ml_he, rocket_ml_heat);
//HUDS
((ItemGunBaseNT) ModItems.gun_debug) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_pepperbox) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
@ -148,4 +164,8 @@ public class GunFactoryClient {
((ItemGunBaseNT) ModItems.gun_maresleg_akimbo) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY_MIRROR, LegoClient.HUD_COMPONENT_AMMO_MIRROR);
((ItemGunBaseNT) ModItems.gun_maresleg_akimbo) .getConfig(null, 1).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
}
public static void setRendererBulk(BiConsumer<EntityBulletBaseMK4, Float> renderer, BulletConfig... configs) {
for(BulletConfig config : configs) config.setRenderer(renderer);
}
}

View File

@ -29,7 +29,7 @@ import net.minecraft.util.MovingObjectPosition;
public class XFactory40mm {
public static BulletConfig g40_flare;
public static BulletConfig g40;
public static BulletConfig g40_he;
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_STANDARD_EXPLODE = (bullet, mop) -> {
Lego.standardExplode(bullet, mop, 5F); bullet.setDead();
@ -38,7 +38,7 @@ public class XFactory40mm {
public static void init() {
g40_flare = new BulletConfig().setItem(EnumAmmo.G40_FLARE).setLife(100).setVel(2F).setGrav(0.035D).setRenderRotations(false).setCasing(new SpentCasing(CasingType.STRAIGHT).setColor(0x9E1616).setScale(2F).register("G40Flare"));
g40 = new BulletConfig().setItem(EnumAmmo.G40).setLife(200).setOnImpact(LAMBDA_STANDARD_EXPLODE).setVel(2F).setGrav(0.035D).setCasing(new SpentCasing(CasingType.STRAIGHT).setColor(SpentCasing.COLOR_CASE_40MM).setScale(2, 2F, 1.5F).register("G40"));
g40_he = new BulletConfig().setItem(EnumAmmo.G40_HE).setLife(200).setOnImpact(LAMBDA_STANDARD_EXPLODE).setVel(2F).setGrav(0.035D).setCasing(new SpentCasing(CasingType.STRAIGHT).setColor(SpentCasing.COLOR_CASE_40MM).setScale(2, 2F, 1.5F).register("G40"));
ModItems.gun_flaregun = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig()
.dura(100).draw(7).inspect(39).crosshair(Crosshair.L_CIRCUMFLEX).smoke(LAMBDA_SMOKE)
@ -55,7 +55,7 @@ public class XFactory40mm {
.dura(400).draw(7).inspect(39).reloadSequential(true).crosshair(Crosshair.L_CIRCUMFLEX).smoke(LAMBDA_SMOKE)
.rec(new Receiver(0)
.dmg(30F).delay(24).reload(16, 16, 16, 0).jam(0).sound("hbm:weapon.glShoot", 1.0F, 1.0F)
.mag(new MagazineSingleReload(0, 4).addConfigs(g40, g40_flare))
.mag(new MagazineSingleReload(0, 4).addConfigs(g40_he, g40_flare))
.offset(0.75, -0.0625, -0.1875D)
.setupStandardFire().recoil(Lego.LAMBDA_STANDARD_RECOIL))
.setupStandardConfiguration()

View File

@ -31,6 +31,9 @@ import net.minecraft.util.Vec3;
public class XFactoryRocket {
public static BulletConfig rocket_he; //TODO: just make this a fucking array you moron
public static BulletConfig rocket_heat; //TODO: so the amount of lines increases linearly instead of exponentially
public static BulletConfig rocket_rpzb_he;
public static BulletConfig rocket_rpzb_heat;
public static BulletConfig rocket_qd_he;
@ -38,16 +41,16 @@ public class XFactoryRocket {
public static BulletConfig rocket_ml_he;
public static BulletConfig rocket_ml_heat;
// FLYING
public static Consumer<EntityBulletBaseMK4> LAMBDA_STANDARD_ACCELERATE = (bullet) -> {
if(bullet.accel < 7) bullet.accel += 0.4D;
};
public static Consumer<EntityBulletBaseMK4> LAMBDA_STEERING_ACCELERATE = (bullet) -> {
if(bullet.accel < 4) bullet.accel += 0.4D;
if(bullet.getThrower() == null || !(bullet.getThrower() instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) bullet.getThrower();
if(Vec3.createVectorHelper(bullet.posX - player.posX, bullet.posY - player.posY, bullet.posZ - player.posZ).lengthVector() > 100) return;
if(player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemGunBaseNT) || !ItemGunBaseNT.getIsAiming(player.getHeldItem())) return;
MovingObjectPosition mop = Library.rayTrace(player, 200, 1);
@ -58,34 +61,42 @@ public class XFactoryRocket {
vec = vec.normalize();
double speed = Vec3.createVectorHelper(bullet.motionX, bullet.motionY, bullet.motionZ).lengthVector();
bullet.motionX = vec.xCoord * speed;
bullet.motionY = vec.yCoord * speed;
bullet.motionZ = vec.zCoord * speed;
};
// IMPACT
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_STANDARD_EXPLODE = (bullet, mop) -> {
if(mop.typeOfHit == mop.typeOfHit.ENTITY && bullet.ticksExisted < 3) return;
Lego.standardExplode(bullet, mop, 5F); bullet.setDead();
};
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_STANDARD_EXPLODE_HEAT = (bullet, mop) -> {
if(mop.typeOfHit == mop.typeOfHit.ENTITY && bullet.ticksExisted < 3) return;
Lego.standardExplode(bullet, mop, 3F, 0.25F); bullet.setDead();
Lego.standardExplode(bullet, mop, 2.5F); bullet.setDead();
};
public static BulletConfig makeRPZB(BulletConfig original) { return original.clone(); }
public static BulletConfig makeQD(BulletConfig original) { return original.clone().setLife(400).setOnUpdate(LAMBDA_STEERING_ACCELERATE); }
public static BulletConfig makeML(BulletConfig original) { return original.clone(); }
//this is starting to get messy but we need to put this crap *somewhere* and fragmenting it into a billion classes with two methods each just isn't gonna help
public static void init() {
rocket_rpzb_he = new BulletConfig().setItem(EnumAmmo.ROCKET_HE).setLife(300).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
rocket_he = new BulletConfig().setItem(EnumAmmo.ROCKET_HE).setLife(300).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STANDARD_ACCELERATE);
rocket_rpzb_heat = new BulletConfig().setItem(EnumAmmo.ROCKET_HEAT).setLife(300).setDamage(1.5F).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE_HEAT).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STANDARD_ACCELERATE);
rocket_qd_he = new BulletConfig().setItem(EnumAmmo.ROCKET_HE).setLife(400).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STEERING_ACCELERATE);
rocket_qd_heat = new BulletConfig().setItem(EnumAmmo.ROCKET_HEAT).setLife(400).setDamage(1.5F).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE_HEAT).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STEERING_ACCELERATE);
rocket_ml_he = new BulletConfig().setItem(EnumAmmo.ROCKET_HE).setLife(300).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STANDARD_ACCELERATE);
rocket_ml_heat = new BulletConfig().setItem(EnumAmmo.ROCKET_HEAT).setLife(300).setDamage(1.5F).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
rocket_heat = new BulletConfig().setItem(EnumAmmo.ROCKET_HEAT).setLife(300).setDamage(1.5F).setSelfDamageDelay(10).setVel(0F).setGrav(0D)
.setOnImpact(LAMBDA_STANDARD_EXPLODE_HEAT).setOnEntityHit(null).setOnRicochet(null).setOnUpdate(LAMBDA_STANDARD_ACCELERATE);
//not a great solution but it makes the entire ordeal a lot more bearable
rocket_rpzb_he = makeRPZB(rocket_he);
rocket_rpzb_heat = makeRPZB(rocket_heat);
rocket_qd_he = makeQD(rocket_he);
rocket_qd_heat = makeQD(rocket_heat);
rocket_ml_he = makeML(rocket_he);
rocket_ml_heat = makeML(rocket_heat);
ModItems.gun_panzerschreck = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig()
.dura(300).draw(7).inspect(40).crosshair(Crosshair.L_CIRCUMFLEX)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B