This commit is contained in:
Bob 2024-12-03 22:27:09 +01:00
parent 663f08be56
commit 49429c73d9
9 changed files with 90 additions and 36 deletions

View File

@ -3,6 +3,7 @@ package com.hbm.commands;
import com.hbm.config.ItemPoolConfigJSON;
import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.util.ChatBuilder;
import com.hbm.util.DamageResistanceHandler;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
@ -26,6 +27,7 @@ public class CommandReloadRecipes extends CommandBase {
try {
SerializableRecipe.initialize();
ItemPoolConfigJSON.initialize();
DamageResistanceHandler.init();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)"));
} catch(Exception ex) {
sender.addChatMessage(ChatBuilder.start("----------------------------------").color(EnumChatFormatting.GRAY).flush());

View File

@ -26,7 +26,7 @@ public class EntityDummy extends EntityLiving implements IAnimals {
}
@Override @SideOnly(Side.CLIENT) public boolean getAlwaysRenderNameTagForRender() { return true; }
@Override public String getCommandSenderName() { return (int) this.getHealth() + " / " + (int) this.getMaxHealth(); }
@Override public String getCommandSenderName() { return (int) (this.getHealth() * 10) / 10F + " / " + (int) (this.getMaxHealth() * 10) / 10F; }
@Override protected void dropEquipment(boolean b, int i) { }
}

View File

@ -209,7 +209,7 @@ public class BulletConfig implements Cloneable {
EntityLivingBase living = (EntityLivingBase) entity;
float prevHealth = living.getHealth();
EntityDamageUtil.attackEntityFromNT(living, source, bullet.damage, true, false, bullet.config.knockbackMult, bullet.config.armorThresholdNegation, bullet.config.armorPiercingPercent);
EntityDamageUtil.attackEntityFromNT(living, source, bullet.damage, true, true, bullet.config.knockbackMult, bullet.config.armorThresholdNegation, bullet.config.armorPiercingPercent);
float newHealth = living.getHealth();
@ -236,7 +236,7 @@ public class BulletConfig implements Cloneable {
}
EntityLivingBase living = (EntityLivingBase) entity;
EntityDamageUtil.attackEntityFromNT(living, source, bullet.damage, true, false, bullet.config.knockbackMult, bullet.config.armorThresholdNegation, bullet.config.armorPiercingPercent);
EntityDamageUtil.attackEntityFromNT(living, source, bullet.damage, true, true, bullet.config.knockbackMult, bullet.config.armorThresholdNegation, bullet.config.armorPiercingPercent);
if(!living.isEntityAlive()) ConfettiUtil.decideConfetti(living, source);
}
};

View File

@ -131,7 +131,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
case B_SIDE: list.add(EnumChatFormatting.GOLD + "B-Side"); break;
case LEGENDARY: list.add(EnumChatFormatting.RED + "Legendary Weapon"); break;
case SPECIAL: list.add(EnumChatFormatting.AQUA + "Special Weapon"); break;
case SECRET: list.add(EnumChatFormatting.DARK_RED + "SECRET"); break;
case SECRET: list.add((BobMathUtil.getBlink() ? EnumChatFormatting.DARK_RED : EnumChatFormatting.RED) + "SECRET"); break;
case DEBUG: list.add((BobMathUtil.getBlink() ? EnumChatFormatting.YELLOW : EnumChatFormatting.GOLD) + "DEBUG"); break;
}
}

View File

@ -45,7 +45,7 @@ public class XFactory22lr {
ModItems.gun_am180 = new ItemGunBaseNT(WeaponQuality.A_SIDE, new GunConfig()
.dura(177 * 25).draw(15).inspect(38).crosshair(Crosshair.L_CIRCLE).smoke(LAMBDA_SMOKE)
.rec(new Receiver(0)
.dmg(5F).delay(1).dry(10).auto(true).spread(0.02F).reload(66).jam(30).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F)
.dmg(2F).delay(1).dry(10).auto(true).spread(0.02F).reload(66).jam(30).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F)
.mag(new MagazineFullReload(0, 177).addConfigs(p22_sp, p22_fmj, p22_jhp, p22_ap))
.offset(1, -0.0625 * 1.5, -0.1875D)
.setupStandardFire().recoil(Lego.LAMBDA_STANDARD_RECOIL))

View File

@ -99,7 +99,7 @@ public class XFactoryFolly {
folly_nuke = new BulletConfig().setItem(EnumAmmoSecret.FOLLY_NUKE).setChunkloading().setLife(600).setVel(4F).setGrav(0.015D)
.setOnImpact(LAMBDA_NUKE_IMPACT);
ModItems.gun_folly = new ItemGunBaseNT(WeaponQuality.LEGENDARY, new GunConfig()
ModItems.gun_folly = new ItemGunBaseNT(WeaponQuality.SECRET, new GunConfig()
.dura(0).draw(40).crosshair(Crosshair.NONE)
.rec(new Receiver(0)
.dmg(1_000F).delay(26).dryfire(false).reload(160).jam(0).sound("hbm:weapon.fire.loudestNoiseOnEarth", 100.0F, 1.0F)

View File

@ -32,7 +32,7 @@ public class RenderBeam extends Render {
bullet.config.rendererBeam.accept(bullet, interp);
}
if(fog) GL11.glDisable(GL11.GL_FOG);
if(fog) GL11.glEnable(GL11.GL_FOG);
GL11.glPopMatrix();
}

View File

@ -28,8 +28,10 @@ public class DamageResistanceHandler {
public static float currentPDT = 0F;
/** Currently cached armor piercing % */
public static float currentPDR = 0F;
public static final String KEY_EXPLOSION = "EXPL";
public static final String CATEGORY_EXPLOSION = "EXPL";
public static final String CATEGORY_FIRE = "FIRE";
public static final String CATEGORY_PROJECTILE = "PROJ";
public static HashMap<Item, ResistanceStats> itemStats = new HashMap();
public static HashMap<Quartet<Item, Item, Item, Item>, ResistanceStats> setStats = new HashMap();
@ -41,33 +43,73 @@ public class DamageResistanceHandler {
setStats.clear();
entityStats.clear();
entityStats.put(EntityCreeper.class, new ResistanceStats().add(KEY_EXPLOSION, 2F, 0.5F));
entityStats.put(EntityCreeper.class, new ResistanceStats().addCategory(CATEGORY_EXPLOSION, 2F, 0.5F));
setStats.put(new Quartet(ModItems.steel_helmet, ModItems.steel_plate, ModItems.steel_legs, ModItems.steel_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.titanium_helmet, ModItems.titanium_plate, ModItems.titanium_legs, ModItems.titanium_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.alloy_helmet, ModItems.alloy_plate, ModItems.alloy_legs, ModItems.alloy_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.cobalt_helmet, ModItems.cobalt_plate, ModItems.cobalt_legs, ModItems.cobalt_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.alloy_helmet, ModItems.alloy_plate, ModItems.alloy_legs, ModItems.alloy_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 2F, 0.1F));
setStats.put(new Quartet(ModItems.cobalt_helmet, ModItems.cobalt_plate, ModItems.cobalt_legs, ModItems.cobalt_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 2F, 0.1F));
setStats.put(new Quartet(ModItems.starmetal_helmet, ModItems.starmetal_plate, ModItems.starmetal_legs, ModItems.starmetal_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.zirconium_legs, ModItems.zirconium_legs, ModItems.zirconium_legs, ModItems.zirconium_legs), new ResistanceStats());
setStats.put(new Quartet(ModItems.zirconium_legs, ModItems.zirconium_legs, ModItems.zirconium_legs, ModItems.zirconium_legs), new ResistanceStats()
.setOther(0F, 1F));
setStats.put(new Quartet(ModItems.dnt_helmet, ModItems.dnt_plate, ModItems.dnt_legs, ModItems.dnt_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.schrabidium_helmet, ModItems.schrabidium_plate, ModItems.schrabidium_legs, ModItems.schrabidium_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.robes_helmet, ModItems.robes_plate, ModItems.robes_legs, ModItems.robes_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.steamsuit_helmet, ModItems.steamsuit_plate, ModItems.steamsuit_legs, ModItems.steamsuit_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.dieselsuit_helmet, ModItems.dieselsuit_plate, ModItems.dieselsuit_legs, ModItems.dieselsuit_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.t45_helmet, ModItems.t45_plate, ModItems.t45_legs, ModItems.t45_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.ajr_helmet, ModItems.ajr_plate, ModItems.ajr_legs, ModItems.ajr_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.ajro_helmet, ModItems.ajro_plate, ModItems.ajro_legs, ModItems.ajro_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.rpa_helmet, ModItems.rpa_plate, ModItems.rpa_legs, ModItems.rpa_boots), new ResistanceStats());
ResistanceStats bj = new ResistanceStats();
setStats.put(new Quartet(ModItems.t45_helmet, ModItems.t45_plate, ModItems.t45_legs, ModItems.t45_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 2F, 0.15F)
.addCategory(CATEGORY_FIRE, 0.5F, 0.35F)
.addCategory(CATEGORY_EXPLOSION, 5F, 0.25F)
.setOther(0F, 0.1F));
setStats.put(new Quartet(ModItems.ajr_helmet, ModItems.ajr_plate, ModItems.ajr_legs, ModItems.ajr_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 4F, 0.15F)
.addCategory(CATEGORY_FIRE, 0.5F, 0.35F)
.addCategory(CATEGORY_EXPLOSION, 7.5F, 0.25F)
.setOther(0F, 0.15F));
setStats.put(new Quartet(ModItems.ajro_helmet, ModItems.ajro_plate, ModItems.ajro_legs, ModItems.ajro_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 4F, 0.15F)
.addCategory(CATEGORY_FIRE, 0.5F, 0.35F)
.addCategory(CATEGORY_EXPLOSION, 7.5F, 0.25F)
.setOther(0F, 0.15F));
setStats.put(new Quartet(ModItems.rpa_helmet, ModItems.rpa_plate, ModItems.rpa_legs, ModItems.rpa_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 20F, 0.5F)
.addCategory(CATEGORY_FIRE, 10F, 0.75F)
.addCategory(CATEGORY_EXPLOSION, 15F, 0.25F)
.addExact(DamageClass.LASER.name(), 10F, 0.75F)
.setOther(2F, 0.15F));
ResistanceStats bj = new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 5F, 0.25F)
.addCategory(CATEGORY_FIRE, 2.5F, 0.5F)
.addCategory(CATEGORY_EXPLOSION, 10F, 0.25F)
.setOther(2F, 0.15F);
setStats.put(new Quartet(ModItems.bj_helmet, ModItems.bj_plate, ModItems.bj_legs, ModItems.bj_boots), bj);
setStats.put(new Quartet(ModItems.bj_helmet, ModItems.bj_plate_jetpack, ModItems.bj_legs, ModItems.bj_boots), bj);
setStats.put(new Quartet(ModItems.envsuit_helmet, ModItems.envsuit_plate, ModItems.envsuit_legs, ModItems.envsuit_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.hev_helmet, ModItems.hev_plate, ModItems.hev_legs, ModItems.hev_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.bismuth_helmet, ModItems.bismuth_plate, ModItems.bismuth_legs, ModItems.bismuth_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.hev_helmet, ModItems.hev_plate, ModItems.hev_legs, ModItems.hev_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 2F, 0.15F)
.addCategory(CATEGORY_FIRE, 0.5F, 0.5F)
.addCategory(CATEGORY_EXPLOSION, 5F, 0.25F)
.addExact(DamageSource.onFire.damageType, 0F, 1F)
.setOther(2F, 0.25F));
setStats.put(new Quartet(ModItems.bismuth_helmet, ModItems.bismuth_plate, ModItems.bismuth_legs, ModItems.bismuth_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 2F, 0.15F)
.addCategory(CATEGORY_FIRE, 5F, 0.5F)
.addCategory(CATEGORY_EXPLOSION, 5F, 0.25F)
.setOther(2F, 0.25F));
setStats.put(new Quartet(ModItems.fau_helmet, ModItems.fau_plate, ModItems.fau_legs, ModItems.fau_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.dns_helmet, ModItems.dns_plate, ModItems.dns_legs, ModItems.dns_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.trenchmaster_helmet, ModItems.trenchmaster_plate, ModItems.trenchmaster_legs, ModItems.trenchmaster_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.dns_helmet, ModItems.dns_plate, ModItems.dns_legs, ModItems.dns_boots), new ResistanceStats()
.addCategory(CATEGORY_EXPLOSION, 100F, 0.9F)
.setOther(100F, 100F));
setStats.put(new Quartet(ModItems.trenchmaster_helmet, ModItems.trenchmaster_plate, ModItems.trenchmaster_legs, ModItems.trenchmaster_boots), new ResistanceStats()
.addCategory(CATEGORY_PROJECTILE, 5F, 0.5F)
.addCategory(CATEGORY_FIRE, 5F, 0.5F)
.addCategory(CATEGORY_EXPLOSION, 5F, 0.25F)
.addExact(DamageClass.LASER.name(), 15F, 0.9F)
.setOther(5F, 0.25F));
setStats.put(new Quartet(ModItems.hazmat_helmet, ModItems.hazmat_plate, ModItems.hazmat_legs, ModItems.hazmat_boots), new ResistanceStats());
setStats.put(new Quartet(ModItems.hazmat_helmet_red, ModItems.hazmat_plate_red, ModItems.hazmat_legs_red, ModItems.hazmat_boots_red), new ResistanceStats());
@ -103,7 +145,7 @@ public class DamageResistanceHandler {
float amount = event.ammount;
float[] vals = getDTDR(e, event.source, amount, currentPDT, currentPDR);
float dt = vals[0];
float dt = vals[0] - currentPDT;
if(dt > 0 && dt >= event.ammount) {
event.setCanceled(true);
@ -116,13 +158,15 @@ public class DamageResistanceHandler {
event.ammount = calculateDamage(event.entityLiving, event.source, event.ammount, currentPDT, currentPDR);
}
public static String typeToKey(DamageSource source) {
if(source.isExplosion()) return KEY_EXPLOSION;
public static String typeToCategory(DamageSource source) {
if(source.isExplosion()) return CATEGORY_EXPLOSION;
if(source.isFireDamage()) return CATEGORY_FIRE;
if(source.isProjectile()) return CATEGORY_PROJECTILE;
return source.damageType;
}
public static float calculateDamage(EntityLivingBase entity, DamageSource damage, float amount, float pierceDT, float pierce) {
if(damage.isDamageAbsolute() || damage.isUnblockable()) return amount;
if(damage.isDamageAbsolute()) return amount;
float[] vals = getDTDR(entity, damage, amount, pierceDT, pierce);
float dt = vals[0];
@ -138,7 +182,6 @@ public class DamageResistanceHandler {
public static float[] getDTDR(EntityLivingBase entity, DamageSource damage, float amount, float pierceDT, float pierce) {
String key = typeToKey(damage);
float dt = 0;
float dr = 0;
@ -152,7 +195,7 @@ public class DamageResistanceHandler {
ResistanceStats setResistance = setStats.get(wornSet);
if(setResistance != null) {
Resistance res = setResistance.resistances.get(key);
Resistance res = setResistance.getResistance(damage);
if(res != null) {
dt += res.threshold;
dr += res.resistance;
@ -165,7 +208,7 @@ public class DamageResistanceHandler {
if(armor == null) continue;
ResistanceStats stats = itemStats.get(armor.getItem());
if(stats == null) continue;
Resistance res = stats.resistances.get(key);
Resistance res = stats.getResistance(damage);
if(res == null) continue;
dt += res.threshold;
dr += res.resistance;
@ -174,7 +217,7 @@ public class DamageResistanceHandler {
/// ENTITY CLASS HANDLING ///
ResistanceStats innateResistance = entityStats.get(entity.getClass());
if(innateResistance != null) {
Resistance res = innateResistance.resistances.get(key);
Resistance res = innateResistance.getResistance(damage);
if(res != null) {
dt += res.threshold;
dr += res.resistance;
@ -185,13 +228,22 @@ public class DamageResistanceHandler {
}
public static class ResistanceStats {
public HashMap<String, Resistance> exactResistances = new HashMap();
public HashMap<String, Resistance> categoryResistances = new HashMap();
public Resistance otherResistance;
public HashMap<String, Resistance> resistances = new HashMap();
public ResistanceStats add(String type, float threshold, float resistance) {
resistances.put(type, new Resistance(threshold, resistance));
return this;
public Resistance getResistance(DamageSource source) {
Resistance exact = exactResistances.get(source.damageType);
if(exact != null) return exact;
Resistance category = categoryResistances.get(typeToCategory(source));
if(category != null) return category;
return source.isUnblockable() ? null : otherResistance;
}
public ResistanceStats addExact(String type, float threshold, float resistance) { exactResistances.put(type, new Resistance(threshold, resistance)); return this; }
public ResistanceStats addCategory(String type, float threshold, float resistance) { categoryResistances.put(type, new Resistance(threshold, resistance)); return this; }
public ResistanceStats setOther(float threshold, float resistance) { otherResistance = new Resistance(threshold, resistance); return this; }
}
public static class Resistance {

View File

@ -149,7 +149,7 @@ public class EntityDamageUtil {
public static float applyArmorCalculationsNT(EntityLivingBase living, DamageSource source, float amount) {
if(!source.isUnblockable()) {
int i = 25 - living.getTotalArmorValue();
float i = 25F - (living.getTotalArmorValue() * (1 - DamageResistanceHandler.currentPDR));
float armor = amount * (float) i;
damageArmorNT(living, amount);
amount = armor / 25.0F;