UAC pistol, damage util crap, mk5 fix

This commit is contained in:
Boblet 2023-07-10 15:48:09 +02:00
parent b443c3449d
commit de028bb5e1
11 changed files with 17248 additions and 32 deletions

View File

@ -14,4 +14,5 @@ credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion al
\ Toshayo (satellite loot system, project settings, gradle curse task), Silly541 (config for safe ME drives),\
\ Voxelstice (OpenComputers integration, turbine spinup), BallOfEnergy1 (OpenComputers integration), martemen\
\ (project settings), Pvndols (thorium fuel recipe, gas turbine), JamesH2 (blood mechanics, nitric acid,\
\ particle emitter), sdddddf80 (recipe configs, chinese localization), SuperCraftAlex (tooltips)
\ particle emitter), sdddddf80 (recipe configs, chinese localization), SuperCraftAlex (tooltips)\
\ LePeep (coilgun model), Maksymisio (polish localization)

View File

@ -181,6 +181,8 @@ public class ExplosionNukeRayBatched {
Math.abs(posX - (chunkX << 4)),
Math.abs(posZ - (chunkZ << 4)))) - 16; //jump ahead to cut back on NOPs
enter = Math.max(enter, 0);
for(FloatTriplet triplet : list) {
float x = triplet.xCoord;
float y = triplet.yCoord;

View File

@ -68,8 +68,8 @@ public class Gun45ACPFactory {
config.allowsInfinity = true;
config.hasSights = true;
config.crosshair = Crosshair.CROSS;
config.reloadSound = "hbm:weapon.pistolReloadPB3";
config.firingSound = "hbm:weapon.pistolFirePB3";
config.reloadSound = GunConfiguration.RSOUND_MAG;
config.firingSound = "hbm:weapon.deagleShoot";
config.reloadSoundEnd = true;
config.name = "uacPistol";

View File

@ -1617,6 +1617,7 @@ public class ModItems {
public static Item gun_glass_cannon;
public static Item gun_m2;
public static Item gun_lunatic_marksman;
public static Item gun_uac_pistol;
// We'll figure this part out later
//public static Item gun_llr, gun_mlr, gun_hlr, gun_twr, gun_lunatic, gun_lunatic_shotty;
@ -4243,6 +4244,7 @@ public class ModItems {
gun_glass_cannon = new ItemEnergyGunBase(GunPoweredFactory.getGlassCannonConfig()).setFull3D().setUnlocalizedName("gun_glass_cannon").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter");
gun_m2 = new ItemGunBase(Gun50BMGFactory.getM2Config()).setFull3D().setUnlocalizedName("gun_m2").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_darter");
gun_lunatic_marksman = new ItemGunBase(Gun50BMGFactory.getLunaticMarksman()).setFull3D().setUnlocalizedName("gun_lunatic_marksman").setCreativeTab(MainRegistry.weaponTab);
gun_uac_pistol = new ItemGunBase(Gun45ACPFactory.getUACPistolConfig()).setFull3D().setUnlocalizedName("gun_uac_pistol").setCreativeTab(MainRegistry.weaponTab);
ToolMaterial matCrucible = EnumHelper.addToolMaterial("CRUCIBLE", 10, 3, 50.0F, 100.0F, 0);
crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible");
@ -6980,6 +6982,7 @@ public class ModItems {
GameRegistry.registerItem(gun_revolver_red, gun_revolver_red.getUnlocalizedName());
GameRegistry.registerItem(gun_bio_revolver, gun_bio_revolver.getUnlocalizedName());
GameRegistry.registerItem(gun_deagle, gun_deagle.getUnlocalizedName());
GameRegistry.registerItem(gun_uac_pistol, gun_uac_pistol.getUnlocalizedName());
GameRegistry.registerItem(gun_flechette, gun_flechette.getUnlocalizedName());
GameRegistry.registerItem(gun_ar15, gun_ar15.getUnlocalizedName());
GameRegistry.registerItem(gun_calamity, gun_calamity.getUnlocalizedName());

View File

@ -521,6 +521,7 @@ public class ClientProxy extends ServerProxy {
MinecraftForgeClient.registerItemRenderer(ModItems.gun_revolver_red, new ItemRenderWeaponNovac());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_lunatic_marksman, new ItemRenderLunaticSniper());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_benelli, new ItemRenderBenelli());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_uac_pistol, new ItemRenderUACPistol());
MinecraftForgeClient.registerItemRenderer(ModItems.gun_coilgun, new ItemRenderWeaponCoilgun());
//multitool
MinecraftForgeClient.registerItemRenderer(ModItems.multitool_dig, new ItemRenderMultitool());

View File

@ -751,6 +751,7 @@ public class ResourceManager {
public static final IModelCustom tau = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/tau.obj"));
public static final IModelCustom benelli = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/benelli_new.obj")).asDisplayList();
public static final IModelCustom coilgun = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/coilgun.obj")).asDisplayList();
public static final IModelCustom uac_pistol = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/UAC pistol.obj")).asDisplayList(); //TODO: reduce this fat fuck
public static final IModelCustom lance = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/weapons/lance.obj"));
@ -843,6 +844,7 @@ public class ResourceManager {
public static final ResourceLocation tau_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/tau.png");
public static final ResourceLocation benelli_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/benelli_tex.png");
public static final ResourceLocation coilgun_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/coilgun.png");
public static final ResourceLocation uac_pistol_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/pistol_texture.png");
public static final ResourceLocation lance_tex = new ResourceLocation(RefStrings.MODID, "textures/models/weapons/lance.png");

View File

@ -0,0 +1,109 @@
package com.hbm.render.item.weapon;
import org.lwjgl.opengl.GL11;
import com.hbm.main.ResourceManager;
import com.hbm.render.anim.HbmAnimations;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
public class ItemRenderUACPistol implements IItemRenderer {
Minecraft mc = Minecraft.getMinecraft();
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.FIRST_PERSON_MAP ? false : true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return type == ItemRenderType.ENTITY && (helper == ItemRendererHelper.ENTITY_BOBBING || helper == ItemRendererHelper.ENTITY_ROTATION);
}
static final String lower = "lower_pistol_0";
static final String mag = "mag_pistol_0";
static final String slide = "slide_pistol_0";
static final String trigger = "trigger_pistol_0";
static final String hammer = "bool_obj_bool_obj_data.002";
static final float scale1 = 0.05F;
static final float scale2 = 0.025F;
static final float scale3 = 0.05F;
static final float scale4 = 0.55F;
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
mc.renderEngine.bindTexture(ResourceManager.uac_pistol_tex);
EntityPlayer player = mc.thePlayer;
GL11.glShadeModel(GL11.GL_SMOOTH);
double[] slideAnim = HbmAnimations.getRelevantTransformation("SLIDE");
double[] hammerAnim = HbmAnimations.getRelevantTransformation("HAMMER");
switch(type) {
case ENTITY:// Dropped item
GL11.glScalef(scale1, scale1, scale1);
break;
case EQUIPPED:// In hand from other's POV
GL11.glScalef(scale2, scale2, scale2);
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glRotatef(-45F, 1F, 0F, 0F);
GL11.glTranslatef(0F, -12F, 30F);
GL11.glPushMatrix();
ResourceManager.uac_pistol.renderOnly(trigger, mag, lower);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(slideAnim[0], slideAnim[1], slideAnim[2] * 2);
ResourceManager.uac_pistol.renderPart(slide);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotated(hammerAnim[0], 1F, 0F, 0F);
ResourceManager.uac_pistol.renderPart(hammer);
GL11.glPopMatrix();
break;
case EQUIPPED_FIRST_PERSON:// In hand from POV
GL11.glScalef(scale3, scale3, scale3);
GL11.glRotatef(90F, 0F, 1F, 0F);
if(player.isSneaking()) {
GL11.glRotatef(-25F, 1F, 0F, 0F);
GL11.glRotatef(-5F, 0F, 1F, 0F);
GL11.glTranslatef(20.15F, 3.5F, 18F);
} else {
GL11.glRotatef(-35F, 1F, 0F, 0F);
GL11.glTranslatef(0F, -12F, 25F);
}
GL11.glPushMatrix();
GL11.glTranslated(slideAnim[0], slideAnim[1], slideAnim[2] * 2);
ResourceManager.uac_pistol.renderPart(slide);
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotated(hammerAnim[0], 1F, 0F, 0F);
ResourceManager.uac_pistol.renderPart(hammer);
GL11.glPopMatrix();
break;
case INVENTORY:
GL11.glScalef(scale4, scale4, scale4);
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glRotatef(150F, 1F, 0F, 0F);
GL11.glTranslatef(0F, -8F, -24F);
break;
default:
break;
}
if(type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.EQUIPPED)
ResourceManager.uac_pistol.renderAll();
else
ResourceManager.uac_pistol.renderOnly(trigger, mag, lower);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}
}

View File

@ -1,48 +1,24 @@
package com.hbm.util;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import com.hbm.handler.ArmorModHandler;
import com.hbm.items.ModItems;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraftforge.common.ForgeHooks;
public class EntityDamageUtil {
public static boolean attackEntityFromIgnoreIFrame(Entity victim, DamageSource src, float damage) {
if(!victim.attackEntityFrom(src, damage)) {
try {
Field lastDamage = ReflectionHelper.findField(EntityLivingBase.class, "lastDamage", "field_110153_bc");
float dmg = (float) damage + lastDamage.getFloat(victim);
return victim.attackEntityFrom(src, dmg);
} catch (Exception x) {
return false;
}
} else {
return true;
}
}
public static float getLastDamage(Entity victim) {
try {
Field lastDamage = ReflectionHelper.findField(EntityLivingBase.class, "lastDamage", "field_110153_bc");
return lastDamage.getFloat(victim);
} catch(Exception x) {
return 0F;
}
}
public static boolean wasAttackedByV1(DamageSource source) {
if(source instanceof EntityDamageSource) {
@ -64,4 +40,238 @@ public class EntityDamageUtil {
return false;
}
/**
* Attacks the given entity twice, based on a piecring percentage. The second hit sets the damage source to bypass armor.
* The damage source is modified, so you can't reuse damage source instances.
*/
public static boolean attackEntityFromArmorPiercing(Entity victim, DamageSource src, float damage, float piercing) {
if(src.isUnblockable() || piercing == 0) return victim.attackEntityFrom(src, damage);
if(piercing == 1) {
src.setDamageBypassesArmor();
return victim.attackEntityFrom(src, damage);
}
boolean ret = false;
ret |= victim.attackEntityFrom(src, damage * (1F - piercing));
src.setDamageBypassesArmor();
ret |= victim.attackEntityFrom(src, damage * piercing);
return ret;
}
public static boolean attackEntityFromIgnoreIFrame(Entity victim, DamageSource src, float damage) {
if(!victim.attackEntityFrom(src, damage)) {
if(victim instanceof EntityLivingBase) {
damage += ((EntityLivingBase) victim).lastDamage;
}
return victim.attackEntityFrom(src, damage);
} else {
return true;
}
}
/** Currently just a copy of the vanilla damage code */
public static boolean attackEntityFromNT(EntityLivingBase living, DamageSource source, float amount) {
if(ForgeHooks.onLivingAttack(living, source, amount))
return false;
if(living.isEntityInvulnerable()) {
return false;
} else if(living.worldObj.isRemote) {
return false;
} else {
living.entityAge = 0;
if(living.getHealth() <= 0.0F) {
return false;
} else if(source.isFireDamage() && living.isPotionActive(Potion.fireResistance)) {
return false;
} else {
if((source == DamageSource.anvil || source == DamageSource.fallingBlock) && living.getEquipmentInSlot(4) != null) {
living.getEquipmentInSlot(4).damageItem((int) (amount * 4.0F + living.getRNG().nextFloat() * amount * 2.0F), living);
amount *= 0.75F;
}
living.limbSwingAmount = 1.5F;
boolean flag = true;
if((float) living.hurtResistantTime > (float) living.maxHurtResistantTime / 2.0F) {
if(amount <= living.lastDamage) {
return false;
}
damageEntity(living, source, amount - living.lastDamage); //#
living.lastDamage = amount;
flag = false;
} else {
living.lastDamage = amount;
living.prevHealth = living.getHealth();
living.hurtResistantTime = living.maxHurtResistantTime;
damageEntity(living, source, amount); //#
living.hurtTime = living.maxHurtTime = 10;
}
living.attackedAtYaw = 0.0F;
Entity entity = source.getEntity();
if(entity != null) {
if(entity instanceof EntityLivingBase) {
living.setRevengeTarget((EntityLivingBase) entity);
}
if(entity instanceof EntityPlayer) {
living.recentlyHit = 100;
living.attackingPlayer = (EntityPlayer) entity;
} else if(entity instanceof net.minecraft.entity.passive.EntityTameable) {
net.minecraft.entity.passive.EntityTameable entitywolf = (net.minecraft.entity.passive.EntityTameable) entity;
if(entitywolf.isTamed()) {
living.recentlyHit = 100;
living.attackingPlayer = null;
}
}
}
if(flag) {
living.worldObj.setEntityState(living, (byte) 2);
if(source != DamageSource.drown) {
setBeenAttacked(living); //#
}
if(entity != null) {
double d1 = entity.posX - living.posX;
double d0;
for(d0 = entity.posZ - living.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) {
d1 = (Math.random() - Math.random()) * 0.01D;
}
living.attackedAtYaw = (float) (Math.atan2(d0, d1) * 180.0D / Math.PI) - living.rotationYaw;
living.knockBack(entity, amount, d1, d0);
} else {
living.attackedAtYaw = (float) ((int) (Math.random() * 2.0D) * 180);
}
}
String s;
if(living.getHealth() <= 0.0F) {
s = getDeathSound(living); //#
if(flag && s != null) {
living.playSound(s, getSoundVolume(living), getSoundPitch(living)); //#
}
living.onDeath(source);
} else {
s = getHurtSound(living); //#
if(flag && s != null) {
living.playSound(s, getSoundVolume(living), getSoundPitch(living)); //#
}
}
return true;
}
}
}
// in this household we drink gasoline and sniff glue
public static String getDeathSound(EntityLivingBase living) {
Method m = ReflectionHelper.findMethod(EntityLivingBase.class, living, new String[] {"func_70673_aS", "getDeathSound"});
try { return (String) m.invoke(living); } catch(Exception e) { } return "game.neutral.die";
}
public static String getHurtSound(EntityLivingBase living) {
Method m = ReflectionHelper.findMethod(EntityLivingBase.class, living, new String[] {"func_70621_aR", "getHurtSound"});
try { return (String) m.invoke(living); } catch(Exception e) { } return "game.neutral.hurt";
}
public static float getSoundVolume(EntityLivingBase living) {
Method m = ReflectionHelper.findMethod(EntityLivingBase.class, living, new String[] {"func_70599_aP", "getSoundVolume"});
try { return (float) m.invoke(living); } catch(Exception e) { } return 1F;
}
public static float getSoundPitch(EntityLivingBase living) {
Method m = ReflectionHelper.findMethod(EntityLivingBase.class, living, new String[] {"func_70647_i", "getSoundPitch"});
try { return (float) m.invoke(living); } catch(Exception e) { } return 1F;
}
public static void damageEntity(EntityLivingBase living, DamageSource source, float amount) {
if(!living.isEntityInvulnerable()) {
amount = ForgeHooks.onLivingHurt(living, source, amount);
if(amount <= 0)
return;
amount = applyArmorCalculations(living, source, amount); //#
amount = applyPotionDamageCalculations(living, source, amount); //#
float f1 = amount;
amount = Math.max(amount - living.getAbsorptionAmount(), 0.0F);
living.setAbsorptionAmount(living.getAbsorptionAmount() - (f1 - amount));
if(amount != 0.0F) {
float f2 = living.getHealth();
living.setHealth(f2 - amount);
living.func_110142_aN().func_94547_a(source, f2, amount);
living.setAbsorptionAmount(living.getAbsorptionAmount() - amount);
}
}
}
public static float applyArmorCalculations(EntityLivingBase living, DamageSource source, float amount) {
if(!source.isUnblockable()) {
int i = 25 - living.getTotalArmorValue();
float armor = amount * (float) i;
//living.damageArmor(p_70655_2_); //unused
amount = armor / 25.0F;
}
return amount;
}
public static float applyPotionDamageCalculations(EntityLivingBase living, DamageSource source, float amount) {
if(source.isDamageAbsolute()) {
return amount;
} else {
int resistance;
int j;
float f1;
if(living.isPotionActive(Potion.resistance) && source != DamageSource.outOfWorld) {
resistance = (living.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5;
j = 25 - resistance;
f1 = amount * (float) j;
amount = f1 / 25.0F;
}
if(amount <= 0.0F) {
return 0.0F;
} else {
resistance = EnchantmentHelper.getEnchantmentModifierDamage(living.getLastActiveItems(), source);
if(resistance > 20) {
resistance = 20;
}
if(resistance > 0 && resistance <= 20) {
j = 25 - resistance;
f1 = amount * (float) j;
amount = f1 / 25.0F;
}
return amount;
}
}
}
public static void setBeenAttacked(EntityLivingBase living) {
living.velocityChanged = living.getRNG().nextDouble() >= living.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue();
}
}

View File

@ -2,6 +2,10 @@
# Cracks open stupid as shit keywords that are being used wrong because Mojang shouldn't be entrusted with computers.
# After changing anything here, run `./gradlew clean setupDecompWorkspace`, this should scrap all the cached nonsense and patch the src to reflect changes made.
# EntityLivingBase
public net.minecraft.entity.EntityLivingBase * # everything because fuck i'm not doing 500 of these by hand
# public net.minecraft.entity.EntityLivingBase *() # ditto
# EntityCreeper
public net.minecraft.entity.monster.EntityCreeper field_82225_f # fuseTime
public net.minecraft.entity.monster.EntityCreeper func_146077_cc()V # explode

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B