From 52243eb77c96be57e88430f47020c1631976b85b Mon Sep 17 00:00:00 2001 From: Boblet Date: Thu, 2 Feb 2023 16:44:38 +0100 Subject: [PATCH] nails with heads --- .../com/hbm/handler/GunConfiguration.java | 10 ++++- .../handler/guncfg/Gun44MagnumFactory.java | 9 ++++ .../hbm/handler/guncfg/Gun50AEFactory.java | 3 ++ .../com/hbm/main/ModEventHandlerClient.java | 35 +++++++++++++++ .../item/weapon/ItemRenderOverkill.java | 4 ++ .../hbm/render/util/RenderScreenOverlay.java | 42 ++++++++++++++++++ .../assets/hbm/textures/misc/scope_basic.png | Bin 0 -> 5909 bytes 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/assets/hbm/textures/misc/scope_basic.png diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index ab7fe8cca..f771e56da 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -9,6 +9,8 @@ import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; +import net.minecraft.util.ResourceLocation; + public class GunConfiguration implements Cloneable { /** @@ -32,8 +34,14 @@ public class GunConfiguration implements Cloneable { //animations! public HashMap animations = new HashMap(); - //whether ot not to disable crosshais when sneaking + //whether or not to disable crosshair when sneaking 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! + public boolean absoluteFOV = true; + //the target FOV/added FOV modifier when sneaking + public float zoomFOV = 0.0F; //how long the reload animation will play //MUST BE GREATER THAN ZERO ! ! ! diff --git a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java index c7b3707ec..a51751b3a 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java @@ -17,6 +17,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.ItemAmmoEnums.Ammo44Magnum; import com.hbm.lib.HbmCollection; +import com.hbm.lib.RefStrings; import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; @@ -29,6 +30,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; public class Gun44MagnumFactory { @@ -79,6 +81,8 @@ public class Gun44MagnumFactory { return config; } + public static final ResourceLocation pips_amazing_scope_wow = new ResourceLocation(RefStrings.MODID, "textures/misc/scope_basic.png"); + public static GunConfiguration getMacintoshConfig() { GunConfiguration config = getBaseConfig(); @@ -89,6 +93,11 @@ public class Gun44MagnumFactory { config.manufacturer = EnumGunManufacturer.IF; config.comment.add("Poppin' mentats like tic tacs"); + config.hasSights = true; + config.absoluteFOV = true; + config.zoomFOV = 3F; + config.scopeTexture = pips_amazing_scope_wow; + config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.M44_PIP); config.config.addAll(HbmCollection.fourtyFourMagBasic); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java index 7fa8c658f..fb28d5a4a 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java @@ -52,6 +52,9 @@ public class Gun50AEFactory { config.name = "deagle"; config.manufacturer = EnumGunManufacturer.MAGNUM_R_IMI; + config.absoluteFOV = true; + config.zoomFOV = 1.5F; + config.hasSights = true; config.config = HbmCollection.fiftyAE; diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index f375b7a72..a21dd1293 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -19,6 +19,7 @@ import com.hbm.entity.projectile.EntityChopperMine; import com.hbm.extprop.HbmLivingProps; import com.hbm.extprop.HbmPlayerProps; import com.hbm.handler.ArmorModHandler; +import com.hbm.handler.GunConfiguration; import com.hbm.handler.HTTPHandler; import com.hbm.handler.HazmatRegistry; import com.hbm.handler.ImpactWorldHandler; @@ -113,6 +114,7 @@ import net.minecraft.world.World; import net.minecraft.world.WorldProviderSurface; import net.minecraftforge.client.GuiIngameForge; import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.client.event.FOVUpdateEvent; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; @@ -219,6 +221,18 @@ public class ModEventHandlerClient { PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(0, 0, 0, 999, 0)); } + /// HANDLE SCOPE OVERLAY /// + ItemStack held = player.getHeldItem(); + + if(player.isSneaking() && held != null && held.getItem() instanceof ItemGunBase) { + GunConfiguration config = ((ItemGunBase) held.getItem()).mainConfig; + + if(config.scopeTexture != null) { + ScaledResolution resolution = event.resolution; + RenderScreenOverlay.renderScope(resolution, config.scopeTexture); + } + } + /// HANDLE FSB HUD /// ItemStack helmet = player.inventory.armorInventory[3]; @@ -327,6 +341,27 @@ public class ModEventHandlerClient { } } + @SubscribeEvent + public void setupFOV(FOVUpdateEvent event) { + + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack held = player.getHeldItem(); + + if(held == null) return; + if(!(held.getItem() instanceof ItemGunBase)) return; + + GunConfiguration config = ((ItemGunBase) held.getItem()).mainConfig; + + if(config == null) return; + if(config.zoomFOV == 0F || !player.isSneaking()) return; + + if(config.absoluteFOV) { + event.newfov = config.zoomFOV; + } else { + event.newfov += config.zoomFOV; + } + } + public static boolean ducked = false; @SubscribeEvent 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 35f7b5782..3f39188fb 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderOverkill.java @@ -6,6 +6,7 @@ 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; @@ -83,6 +84,9 @@ 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/util/RenderScreenOverlay.java b/src/main/java/com/hbm/render/util/RenderScreenOverlay.java index d4283cc03..7753457aa 100644 --- a/src/main/java/com/hbm/render/util/RenderScreenOverlay.java +++ b/src/main/java/com/hbm/render/util/RenderScreenOverlay.java @@ -5,6 +5,7 @@ import org.lwjgl.opengl.GL12; import com.hbm.extprop.HbmPlayerProps; import com.hbm.interfaces.Spaghetti; +import com.hbm.interfaces.Untested; import com.hbm.lib.RefStrings; import net.minecraft.client.Minecraft; @@ -13,6 +14,7 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -313,6 +315,46 @@ public class RenderScreenOverlay { Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons); } + @Untested + public static void renderScope(ScaledResolution res, ResourceLocation tex) { + + 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); + + Minecraft.getMinecraft().renderEngine.bindTexture(tex); + Tessellator tess = Tessellator.instance; + + double w = res.getScaledWidth_double(); + double h = res.getScaledHeight_double(); + + double wToH = w / h; + double hToW = h / w; + + double lower = 4.5D / 16D; + double upper = 11.5D / 16D; + + 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; + + 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.draw(); + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + public enum Crosshair { NONE(0, 0, 0), diff --git a/src/main/resources/assets/hbm/textures/misc/scope_basic.png b/src/main/resources/assets/hbm/textures/misc/scope_basic.png new file mode 100644 index 0000000000000000000000000000000000000000..4a9fa9eef30ca7614fec619ca9eace8cf8b2d461 GIT binary patch literal 5909 zcmZ{Ic{r49*#0wy8DWr;B0E{KXWwOs$eLaDpKH%TGul&xgRzGdu;ErocI zWwMRD$dVaL2=P5r@Ao^7-yh!`#~ky_dEM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