diff --git a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java index 6cd4a16e3..ccff05ac4 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java +++ b/src/main/java/com/hbm/entity/projectile/EntityBulletBase.java @@ -14,6 +14,8 @@ import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionNukeGeneric; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.GunConfiguration; +import com.hbm.items.weapon.ItemGunBase; import com.hbm.main.MainRegistry; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; @@ -32,6 +34,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; @@ -80,14 +83,29 @@ public class EntityBulletBase extends Entity implements IProjectile { this.config = BulletConfigSyncingUtil.pullConfig(config); this.dataWatcher.updateObject(18, config); shooter = entity; + + ItemStack gun = entity.getHeldItem(); + boolean offsetShot = true; + + if(gun != null && gun.getItem() instanceof ItemGunBase) { + GunConfiguration cfg = ((ItemGunBase) gun.getItem()).mainConfig; + + if(cfg != null && cfg.hasSights && entity.isSneaking()) { + offsetShot = false; + } + } this.setLocationAndAngles(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ, entity.rotationYaw, entity.rotationPitch); - double sideOffset = 0.16D; - - this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * sideOffset; - this.posY -= 0.1D; - this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * sideOffset; + if(offsetShot) { + double sideOffset = 0.16D; + + this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * sideOffset; + this.posY -= 0.1D; + this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * sideOffset; + } else { + this.posY -= 0.1D; + } this.setPosition(this.posX, this.posY, this.posZ); this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI); @@ -97,7 +115,7 @@ public class EntityBulletBase extends Entity implements IProjectile { this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); - this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.0F, this.config.spread); + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.0F, this.config.spread * (offsetShot ? 1F : 0.25F)); this.dataWatcher.updateObject(16, (byte)this.config.style); this.dataWatcher.updateObject(17, (byte)this.config.trail); diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index f771e56da..499af94d0 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -38,9 +38,9 @@ public class GunConfiguration implements Cloneable { public boolean hasSights; //texture overlay when sneaking public ResourceLocation scopeTexture; - //whether the FOV multiplier should be absolute or additive to other modifiers, additive mode is experimental! + //whether the FOV multiplier should be absolute or multiplicative to other modifiers, multiplicative mode is experimental! public boolean absoluteFOV = true; - //the target FOV/added FOV modifier when sneaking + //the target FOV/multiplied FOV modifier when sneaking public float zoomFOV = 0.0F; //how long the reload animation will play diff --git a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java index 7a59cf0e9..9784b8527 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java @@ -12,15 +12,13 @@ import com.hbm.particle.SpentCasing; import com.hbm.particle.SpentCasing.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; -import net.minecraft.util.Vec3; - public class Gun22LRFactory { private static final CasingEjector EJECTOR_22LR; private static final SpentCasing CASING22LR; static { - EJECTOR_22LR = new CasingEjector().setMotion(Vec3.createVectorHelper(-0.4, 0.1, 0)).setOffset(Vec3.createVectorHelper(-0.35, -0.2, 0.35)).setAngleRange(0.01F, 0.03F); + EJECTOR_22LR = new CasingEjector().setMotion(-0.4, 0.1, 0).setOffset(-0.35, -0.2, 0.35).setAngleRange(0.01F, 0.03F); CASING22LR = new SpentCasing(CasingType.STRAIGHT).setScale(0.8F).setBounceMotion(0.05F, 0.02F).setColor(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 a51751b3a..efdc4c796 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java @@ -95,7 +95,7 @@ public class Gun44MagnumFactory { config.hasSights = true; config.absoluteFOV = true; - config.zoomFOV = 3F; + config.zoomFOV = 0.25F; config.scopeTexture = pips_amazing_scope_wow; config.config = new ArrayList(); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java index fb28d5a4a..7374d265d 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java @@ -53,7 +53,7 @@ public class Gun50AEFactory { config.manufacturer = EnumGunManufacturer.MAGNUM_R_IMI; config.absoluteFOV = true; - config.zoomFOV = 1.5F; + config.zoomFOV = 0.5F; config.hasSights = true; config.config = HbmCollection.fiftyAE; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java index e315fc20b..63739ac6b 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -31,12 +31,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; public class Gun556mmFactory { - + private static final CasingEjector EJECTOR_RIFLE; + private static final CasingEjector EJECTOR_GRENADE; private static final SpentCasing CASING556; static { EJECTOR_RIFLE = new CasingEjector().setMotion(-0.35, 0.6, 0).setOffset(-0.35, 0, 0.35).setAngleRange(0.01F, 0.03F); + EJECTOR_GRENADE = new CasingEjector().setAngleRange(0.02F, 0.03F); CASING556 = new SpentCasing(CasingType.BOTTLENECK).setScale(1.25F).setBounceMotion(0.01F, 0.03F).setColor(SpentCasing.COLOR_CASE_BRASS); } @@ -133,6 +135,8 @@ public class Gun556mmFactory { config.config = HbmCollection.grenade; + config.ejector = EJECTOR_GRENADE; + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java index b7ec074fd..7fa4b6bc8 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java @@ -1,16 +1,27 @@ package com.hbm.handler.guncfg; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ItemAmmoEnums.Ammo5mm; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasing; +import com.hbm.particle.SpentCasing.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class Gun5mmFactory { + private static final CasingEjector EJECTOR_MINIGUN; + private static final SpentCasing CASING5MM; + + static { + EJECTOR_MINIGUN = new CasingEjector().setMotion(-0.4, 0.1, 0).setOffset(-0.35, -0.2, 0.35).setAngleRange(0.01F, 0.03F).setAmount(5); + CASING5MM = new SpentCasing(CasingType.STRAIGHT).setScale(1F).setBounceMotion(0.05F, 0.02F).setColor(SpentCasing.COLOR_CASE_BRASS); + } + public static GunConfiguration getMinigunConfig() { GunConfiguration config = new GunConfiguration(); @@ -30,6 +41,8 @@ public class Gun5mmFactory { config.config = HbmCollection.fiveMM; + config.ejector = EJECTOR_MINIGUN; + return config; } @@ -77,6 +90,8 @@ public class Gun5mmFactory { bullet.dmgMin = 12; bullet.dmgMax = 14; + bullet.spentCasing = CASING5MM.clone().register("5mmStock"); + return bullet; } @@ -91,6 +106,8 @@ public class Gun5mmFactory { bullet.explosive = 1F; bullet.wear = 25; + bullet.spentCasing = CASING5MM.clone().register("5mmExp"); + return bullet; } @@ -105,6 +122,8 @@ public class Gun5mmFactory { bullet.wear = 25; bullet.leadChance = 50; + bullet.spentCasing = CASING5MM.clone().register("5mmDU"); + return bullet; } @@ -119,6 +138,8 @@ public class Gun5mmFactory { bullet.wear = 25; bullet.leadChance = 100; + bullet.spentCasing = CASING5MM.clone().register("5mmStar"); + return bullet; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java index 24d40cefe..13f5f1d63 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java @@ -3,12 +3,15 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.ItemAmmoEnums.Ammo762NATO; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasing; +import com.hbm.particle.SpentCasing.CasingType; import com.hbm.potion.HbmPotion; import com.hbm.render.util.RenderScreenOverlay.Crosshair; @@ -16,6 +19,14 @@ import net.minecraft.potion.PotionEffect; public class Gun762mmFactory { + private static final CasingEjector EJECTOR_RIFLE; + private static final SpentCasing CASING762NATO; + + static { + EJECTOR_RIFLE = new CasingEjector().setMotion(-0.35, 0.6, 0).setOffset(-0.35, 0, 0.35).setAngleRange(0.01F, 0.03F); + CASING762NATO = new SpentCasing(CasingType.BOTTLENECK).setScale(1.7F).setBounceMotion(0.01F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS); + } + public static GunConfiguration getUACDMRConfig() { final GunConfiguration config = new GunConfiguration(); @@ -39,6 +50,8 @@ public class Gun762mmFactory { config.manufacturer = EnumGunManufacturer.UAC; config.config.addAll(HbmCollection.threeZeroEight); + + config.ejector = EJECTOR_RIFLE; return config; } @@ -92,6 +105,8 @@ public class Gun762mmFactory { config.comment.add("\"Get some!\""); config.comment.add(" ~ Stuart Brown (aka Ahoy)"); config.config.addAll(HbmCollection.threeZeroEight); + + config.ejector = EJECTOR_RIFLE; return config; } @@ -105,6 +120,8 @@ public class Gun762mmFactory { bullet.velocity *= 2.5; bullet.maxAge *= 2; bullet.spread /= 2; + + bullet.spentCasing = CASING762NATO.clone().register("762NATOStock"); return bullet; } @@ -115,6 +132,8 @@ public class Gun762mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_762.stackFromEnum(Ammo762NATO.AP)); bullet.dmgMax *= 1.5; bullet.dmgMin *= 1.5; + + bullet.spentCasing = CASING762NATO.clone().register("762NATOAP"); return bullet; } @@ -125,6 +144,8 @@ public class Gun762mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_762.stackFromEnum(Ammo762NATO.DU)); bullet.dmgMax *= 2; bullet.dmgMin *= 2; + + bullet.spentCasing = CASING762NATO.clone().register("762NATODU"); return bullet; } @@ -134,6 +155,8 @@ public class Gun762mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_762.stackFromEnum(Ammo762NATO.TRACER)); bullet.vPFX = "reddust"; + + bullet.spentCasing = CASING762NATO.clone().register("762NATOTrac"); return bullet; } @@ -148,6 +171,8 @@ public class Gun762mmFactory { eff.getCurativeItems().clear(); bullet.effects = new ArrayList(); bullet.effects.add(new PotionEffect(eff)); + + bullet.spentCasing = CASING762NATO.clone().register("762NATOPhos"); return bullet; } @@ -159,6 +184,8 @@ public class Gun762mmFactory { bullet.dmgMax = 0; bullet.dmgMin = 0; bullet.maxAge = 0; + + bullet.spentCasing = CASING762NATO.clone().register("762NATOK"); return bullet; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java index c90abc0d6..827950fd8 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java @@ -4,15 +4,26 @@ import java.util.ArrayList; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.ItemAmmoEnums.Ammo9mm; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasing; +import com.hbm.particle.SpentCasing.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class Gun9mmFactory { + private static final CasingEjector EJECTOR_SMG; + private static final SpentCasing CASING9MM; + + static { + EJECTOR_SMG = new CasingEjector().setMotion(-0.3, 0.6, 0).setOffset(-0.35, -0.2, 0.55).setAngleRange(0.01F, 0.03F); + CASING9MM = new SpentCasing(CasingType.STRAIGHT).setScale(1F, 1F, 0.6F).setBounceMotion(0.01F, 0.03F).setColor(SpentCasing.COLOR_CASE_BRASS); + } + public static GunConfiguration getMP40Config() { GunConfiguration config = new GunConfiguration(); @@ -42,6 +53,8 @@ public class Gun9mmFactory { config.config.add(BulletConfigSyncingUtil.CHL_P9); config.config.add(BulletConfigSyncingUtil.P9_ROCKET); + config.ejector = EJECTOR_SMG; + return config; } @@ -88,6 +101,8 @@ public class Gun9mmFactory { bullet.dmgMin = 10; bullet.dmgMax = 14; + bullet.spentCasing = CASING9MM.clone().register("9MMStock"); + return bullet; } @@ -102,6 +117,8 @@ public class Gun9mmFactory { bullet.leadChance = 10; bullet.wear = 15; + bullet.spentCasing = CASING9MM.clone().register("9MMAP"); + return bullet; } @@ -116,6 +133,8 @@ public class Gun9mmFactory { bullet.leadChance = 50; bullet.wear = 25; + bullet.spentCasing = CASING9MM.clone().register("9MMDU"); + return bullet; } @@ -128,6 +147,8 @@ public class Gun9mmFactory { bullet.explosive = 7.5F; bullet.trail = 5; + bullet.spentCasing = CASING9MM.clone().register("9MMRocket"); + return bullet; } diff --git a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java index 0ad90be49..329f2ebfa 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java @@ -5,16 +5,27 @@ import java.util.ArrayList; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.interfaces.IBulletImpactBehavior; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.ItemAmmoEnums.AmmoGrenade; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasing; +import com.hbm.particle.SpentCasing.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class GunGrenadeFactory { + private static final CasingEjector EJECTOR_LAUNCHER; + private static final SpentCasing CASING40MM; + + static { + EJECTOR_LAUNCHER = new CasingEjector().setAngleRange(0.02F, 0.03F).setAfterReload(); + CASING40MM = new SpentCasing(CasingType.STRAIGHT).setScale(4F, 4F, 3F).setBounceMotion(0.02F, 0.03F).setColor(0x777777); + } + public static GunConfiguration getHK69Config() { GunConfiguration config = new GunConfiguration(); @@ -51,6 +62,8 @@ public class GunGrenadeFactory { config.config.add(BulletConfigSyncingUtil.GRENADE_KAMPF); config.durability = 300; + config.ejector = EJECTOR_LAUNCHER; + return config; } @@ -65,6 +78,8 @@ public class GunGrenadeFactory { bullet.wear = 10; bullet.trail = 0; + bullet.spentCasing = CASING40MM.clone().register("40MMStock"); + return bullet; } @@ -80,6 +95,8 @@ public class GunGrenadeFactory { bullet.explosive = 5.0F; bullet.trail = 1; + bullet.spentCasing = CASING40MM.clone().register("40MMHE"); + return bullet; } @@ -95,6 +112,8 @@ public class GunGrenadeFactory { bullet.trail = 0; bullet.incendiary = 2; + bullet.spentCasing = CASING40MM.clone().register("40MMInc"); + return bullet; } @@ -112,6 +131,8 @@ public class GunGrenadeFactory { bullet.bImpact = BulletConfigFactory.getPhosphorousEffect(10, 60 * 20, 100, 0.5D, 1F); + bullet.spentCasing = CASING40MM.clone().register("40MMPhos"); + return bullet; } @@ -128,6 +149,8 @@ public class GunGrenadeFactory { bullet.explosive = 0; bullet.chlorine = 50; + bullet.spentCasing = CASING40MM.clone().register("40MMTox"); + return bullet; } @@ -144,6 +167,8 @@ public class GunGrenadeFactory { bullet.explosive = 7.5F; bullet.jolt = 6.5D; + bullet.spentCasing = CASING40MM.clone().register("40MMIF"); + return bullet; } @@ -159,6 +184,8 @@ public class GunGrenadeFactory { bullet.explosive = 10.0F; bullet.trail = 3; + bullet.spentCasing = CASING40MM.clone().register("40MMCon"); + return bullet; } @@ -171,6 +198,8 @@ public class GunGrenadeFactory { bullet.explosive = 1.5F; bullet.trail = 5; + bullet.spentCasing = CASING40MM.clone().register("40MMFin"); + return bullet; } @@ -190,6 +219,8 @@ public class GunGrenadeFactory { } }; + bullet.spentCasing = CASING40MM.clone().register("40MMNuke"); + return bullet; } @@ -204,6 +235,8 @@ public class GunGrenadeFactory { bullet.trail = 5; bullet.vPFX = "bluedust"; + bullet.spentCasing = CASING40MM.clone().register("40MMTrac").setColor(0xEEEEEE); + return bullet; } @@ -220,6 +253,8 @@ public class GunGrenadeFactory { bullet.trail = 4; bullet.vPFX = "smoke"; + //bullet.spentCasing = CASING40MM.clone().register("40MMKampf").setColor(0xEBC35E); //does not eject, whole cartridge leaves the gun + return bullet; } } diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index a21dd1293..e7c1cbbe5 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -224,7 +224,7 @@ public class ModEventHandlerClient { /// HANDLE SCOPE OVERLAY /// ItemStack held = player.getHeldItem(); - if(player.isSneaking() && held != null && held.getItem() instanceof ItemGunBase) { + if(player.isSneaking() && held != null && held.getItem() instanceof ItemGunBase && event.type == event.type.HOTBAR) { GunConfiguration config = ((ItemGunBase) held.getItem()).mainConfig; if(config.scopeTexture != null) { diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java index 3f39188fb..35f7b5782 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java @@ -6,7 +6,6 @@ import com.hbm.items.ModItems; import com.hbm.items.weapon.GunFolly; import com.hbm.items.weapon.ItemGunBase; import com.hbm.lib.RefStrings; -import com.hbm.main.MainRegistry; import com.hbm.render.model.ModelCalBarrel; import com.hbm.render.model.ModelCalDualStock; import com.hbm.render.model.ModelCalStock; @@ -84,9 +83,6 @@ public class ItemRenderOverkill implements IItemRenderer { if((Entity)data[1] instanceof EntityPlayer) f = ((EntityPlayer)data[1]).getItemInUseDuration(); - //prevent rendering when using scope - if(item.getItem() == ModItems.gun_revolver_pip && type == ItemRenderType.EQUIPPED_FIRST_PERSON && MainRegistry.proxy.me().isSneaking()) return; - switch(type) { case EQUIPPED_FIRST_PERSON: GL11.glPushMatrix(); diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponNovac.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponNovac.java index 0df9e0b12..f99591f9d 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponNovac.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponNovac.java @@ -3,6 +3,7 @@ package com.hbm.render.item.weapon; import org.lwjgl.opengl.GL11; import com.hbm.items.ModItems; +import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; import net.minecraft.client.Minecraft; @@ -34,6 +35,9 @@ public class ItemRenderWeaponNovac implements IItemRenderer { @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + //prevent rendering when using scope + if(item.getItem() == ModItems.gun_revolver_pip && type == ItemRenderType.EQUIPPED_FIRST_PERSON && MainRegistry.proxy.me().isSneaking()) return; + GL11.glPushMatrix(); GL11.glEnable(GL11.GL_CULL_FACE); diff --git a/src/main/java/com/hbm/render/util/RenderScreenOverlay.java b/src/main/java/com/hbm/render/util/RenderScreenOverlay.java index 7753457aa..50ef61541 100644 --- a/src/main/java/com/hbm/render/util/RenderScreenOverlay.java +++ b/src/main/java/com/hbm/render/util/RenderScreenOverlay.java @@ -36,59 +36,56 @@ public class RenderScreenOverlay { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(false); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_ALPHA_TEST); - - float radiation = 0; - - radiation = lastResult - prevResult; - - if(System.currentTimeMillis() >= lastSurvey + 1000) { - lastSurvey = System.currentTimeMillis(); - prevResult = lastResult; - lastResult = in; - } - + // GL11.glDisable(GL11.GL_DEPTH_TEST); + // GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + float radiation = 0; + + radiation = lastResult - prevResult; + + if(System.currentTimeMillis() >= lastSurvey + 1000) { + lastSurvey = System.currentTimeMillis(); + prevResult = lastResult; + lastResult = in; + } + int length = 74; int maxRad = 1000; - + int bar = getScaled(in, maxRad, 74); - - //if(radiation >= 1 && radiation <= 999) - // bar -= (1 + Minecraft.getMinecraft().theWorld.rand.nextInt(3)); - + int posX = 16; int posY = resolution.getScaledHeight() - 18 - 2; Minecraft.getMinecraft().renderEngine.bindTexture(misc); - gui.drawTexturedModalRect(posX, posY, 0, 0, 94, 18); - gui.drawTexturedModalRect(posX + 1, posY + 1, 1, 19, bar, 16); - - if(radiation >= 25) { - gui.drawTexturedModalRect(posX + length + 2, posY - 18, 36, 36, 18, 18); - - } else if(radiation >= 10) { - gui.drawTexturedModalRect(posX + length + 2, posY - 18, 18, 36, 18, 18); - - } else if(radiation >= 2.5) { - gui.drawTexturedModalRect(posX + length + 2, posY - 18, 0, 36, 18, 18); - - } - + gui.drawTexturedModalRect(posX, posY, 0, 0, 94, 18); + gui.drawTexturedModalRect(posX + 1, posY + 1, 1, 19, bar, 16); + + if(radiation >= 25) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 36, 36, 18, 18); + + } else if(radiation >= 10) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 18, 36, 18, 18); + + } else if(radiation >= 2.5) { + gui.drawTexturedModalRect(posX + length + 2, posY - 18, 0, 36, 18, 18); + + } + if(radiation > 1000) { Minecraft.getMinecraft().fontRenderer.drawString(">1000 RAD/s", posX, posY - 8, 0xFF0000); } else if(radiation >= 1) { - Minecraft.getMinecraft().fontRenderer.drawString(((int)Math.round(radiation)) + " RAD/s", posX, posY - 8, 0xFF0000); + Minecraft.getMinecraft().fontRenderer.drawString(((int) Math.round(radiation)) + " RAD/s", posX, posY - 8, 0xFF0000); } else if(radiation > 0) { Minecraft.getMinecraft().fontRenderer.drawString("<1 RAD/s", posX, posY - 8, 0xFF0000); } - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(true); - GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GL11.glPopMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons); } @@ -319,8 +316,8 @@ public class RenderScreenOverlay { public static void renderScope(ScaledResolution res, ResourceLocation tex) { GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDepthMask(false); + //GL11.glDisable(GL11.GL_DEPTH_TEST); + //GL11.glDepthMask(false); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); @@ -328,25 +325,27 @@ public class RenderScreenOverlay { Minecraft.getMinecraft().renderEngine.bindTexture(tex); Tessellator tess = Tessellator.instance; - double w = res.getScaledWidth_double(); - double h = res.getScaledHeight_double(); + double w = res.getScaledWidth(); + double h = res.getScaledHeight(); - double wToH = w / h; - double hToW = h / w; - - double lower = 4.5D / 16D; - double upper = 11.5D / 16D; + double smallest = Math.min(w, h); + double divisor = smallest / (9D / 16D); + smallest = 9D / 16D; + double largest = Math.max(w, h) / divisor; - double hMin = h < w ? lower : 0.5D - (9D / 32D) * hToW; - double hMax = h < w ? upper : 0.5D + (9D / 32D) * hToW; - double wMin = w < h ? lower : 0.5D - (9D / 32D) * wToH; - double wMax = w < h ? upper : 0.5D + (9D / 32D) * wToH; + double hMin = h < w ? 0.5 - smallest / 2D : 0.5 - largest / 2D; + double hMax = h < w ? 0.5 + smallest / 2D : 0.5 + largest / 2D; + double wMin = w < h ? 0.5 - smallest / 2D : 0.5 - largest / 2D; + double wMax = w < h ? 0.5 + smallest / 2D : 0.5 + largest / 2D; + + double depth = -300D; tess.startDrawingQuads(); - tess.addVertexWithUV(0, 0, 0, wMin, 1D - hMin); - tess.addVertexWithUV(w, 0, 0, wMax, 1D - hMin); - tess.addVertexWithUV(w, 0, h, wMax, 1D - hMax); - tess.addVertexWithUV(0, 0, h, wMin, 1D - hMax); + + tess.addVertexWithUV(0, h, depth, wMin, hMax); + tess.addVertexWithUV(w, h, depth, wMax, hMax); + tess.addVertexWithUV(w, 0, depth, wMax, hMin); + tess.addVertexWithUV(0, 0, depth, wMin, hMin); tess.draw(); GL11.glDepthMask(true);