From ee64427cfb5839127051b19019bbe4f6487f7c9d Mon Sep 17 00:00:00 2001 From: mbg206 Date: Fri, 30 Dec 2022 15:59:36 -0600 Subject: [PATCH] Updated Controllable --- build.gradle | 4 +- .../java/com/mrcrayfish/guns/Reference.java | 2 +- .../guns/client/ControllerEvents.java | 53 +++++++------------ .../render/gun/model/ModelChainGun.java | 3 +- .../mrcrayfish/guns/proxy/ClientProxy.java | 3 +- src/main/resources/mcmod.info | 2 +- 6 files changed, 26 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index 08a64997d..57e863919 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "0.15.2-1.12.2" +version = "0.15.3-1.12.2" group = "com.mrcrayfish.guns" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "guns" @@ -42,7 +42,7 @@ repositories { dependencies { compile 'obfuscate:Obfuscate:0.2.6:1.12.2' - provided 'controllable:Controllable:1.12.2:0.3.0' + provided 'controllable:Controllable:1.12.2:0.8.0' } processResources { diff --git a/src/main/java/com/mrcrayfish/guns/Reference.java b/src/main/java/com/mrcrayfish/guns/Reference.java index 8d7ed541d..8721ca09b 100644 --- a/src/main/java/com/mrcrayfish/guns/Reference.java +++ b/src/main/java/com/mrcrayfish/guns/Reference.java @@ -4,7 +4,7 @@ public class Reference { public static final String MOD_ID = "cgm"; public static final String MOD_NAME = "MrCrayfish's Gun Mod"; - public static final String MOD_VERSION = "0.15.2"; + public static final String MOD_VERSION = "0.15.3"; public static final String MC_VERSION = "[1.12.2]"; public static final String DEPENDENCIES = "required-after:obfuscate@[0.2.1,);after:controllable@[0.3.0,)"; public static final String PROXY_CLIENT = "com.mrcrayfish.guns.proxy.ClientProxy"; diff --git a/src/main/java/com/mrcrayfish/guns/client/ControllerEvents.java b/src/main/java/com/mrcrayfish/guns/client/ControllerEvents.java index b6fe62464..9724bef0f 100644 --- a/src/main/java/com/mrcrayfish/guns/client/ControllerEvents.java +++ b/src/main/java/com/mrcrayfish/guns/client/ControllerEvents.java @@ -28,7 +28,6 @@ */ public class ControllerEvents { - private boolean shooting = false; private int reloadCounter = -1; @SubscribeEvent @@ -36,7 +35,7 @@ public void onButtonInput(ControllerEvent.ButtonInput event) { EntityPlayer player = Minecraft.getMinecraft().player; World world = Minecraft.getMinecraft().world; - if(player != null && world != null) + if(player != null && world != null && Minecraft.getMinecraft().currentScreen == null) { ItemStack heldItem = player.getHeldItemMainhand(); switch(event.getButton()) @@ -52,11 +51,6 @@ public void onButtonInput(ControllerEvent.ButtonInput event) } break; case Buttons.LEFT_TRIGGER: - if(heldItem.getItem() instanceof ItemGun) - { - event.setCanceled(true); - } - break; case Buttons.RIGHT_THUMB_STICK: if(heldItem.getItem() instanceof ItemGun) { @@ -69,7 +63,7 @@ public void onButtonInput(ControllerEvent.ButtonInput event) event.setCanceled(true); if(event.getState()) { - reloadCounter = 0; + this.reloadCounter = 0; } } break; @@ -93,27 +87,14 @@ public void onControllerTurn(ControllerEvent.Turn event) if (scope != null) { ItemScope.Type scopeType = ItemScope.Type.getFromStack(scope); - if(scopeType != null) + switch(scopeType) { - switch(scopeType) - { - case LONG: - if(event.getController().getState().rightStickClick) - { - event.setYawSpeed(1.5F); - event.setPitchSpeed(1.0F); - } - else - { - event.setYawSpeed(3.5F); - event.setPitchSpeed(3.0F); - } - break; - case MEDIUM: - event.setYawSpeed(6.66F); - event.setPitchSpeed(5.0F); - break; - } + case LONG: + case MEDIUM: + boolean isSteadyAiming = event.getController().isButtonPressed(Buttons.RIGHT_THUMB_STICK); + event.setYawSpeed(isSteadyAiming ? 2.5F : 5.0F); + event.setPitchSpeed(isSteadyAiming ? 1.875F : 3.75F); + break; } } } @@ -124,8 +105,7 @@ public void onControllerTurn(ControllerEvent.Turn event) public void updateAvailableActions(AvailableActionsEvent event) { Minecraft mc = Minecraft.getMinecraft(); - if(mc.currentScreen != null) - return; + if(mc.currentScreen != null) return; EntityPlayer player = Minecraft.getMinecraft().player; if(player != null) @@ -147,9 +127,12 @@ public void updateAvailableActions(AvailableActionsEvent event) if (scope != null && MrCrayfishGunMod.proxy.isZooming()) { ItemScope.Type scopeType = ItemScope.Type.getFromStack(scope); - if(scopeType == ItemScope.Type.LONG) + switch(scopeType) { - event.getActions().put(Buttons.RIGHT_THUMB_STICK, new Action("Hold Breath", Action.Side.RIGHT)); + case LONG: + case MEDIUM: + event.getActions().put(Buttons.RIGHT_THUMB_STICK, new Action("Steady Aim", Action.Side.RIGHT)); + break; } } } @@ -171,7 +154,7 @@ public void onRender(TickEvent.RenderTickEvent event) if(player == null) return; - if(controller.getState().rightTrigger > 0.05) + if(controller.isButtonPressed(Buttons.RIGHT_TRIGGER) && Minecraft.getMinecraft().currentScreen == null) { ItemStack heldItem = player.getHeldItemMainhand(); if(heldItem.getItem() instanceof ItemGun) @@ -186,7 +169,7 @@ public void onRender(TickEvent.RenderTickEvent event) if(mc.currentScreen == null && reloadCounter != -1) { - if(controller.getState().x) + if(controller.isButtonPressed(Buttons.X)) { reloadCounter++; } @@ -198,7 +181,7 @@ public void onRender(TickEvent.RenderTickEvent event) PacketHandler.INSTANCE.sendToServer(new MessageUnload()); reloadCounter = -1; } - else if(reloadCounter > 0 && !controller.getState().x) + else if(reloadCounter > 0 && !controller.isButtonPressed(Buttons.X)) { if(!Minecraft.getMinecraft().player.getDataManager().get(CommonEvents.RELOADING)) { diff --git a/src/main/java/com/mrcrayfish/guns/client/render/gun/model/ModelChainGun.java b/src/main/java/com/mrcrayfish/guns/client/render/gun/model/ModelChainGun.java index 7742d8994..705c14458 100644 --- a/src/main/java/com/mrcrayfish/guns/client/render/gun/model/ModelChainGun.java +++ b/src/main/java/com/mrcrayfish/guns/client/render/gun/model/ModelChainGun.java @@ -1,6 +1,7 @@ package com.mrcrayfish.guns.client.render.gun.model; import com.mrcrayfish.controllable.Controllable; +import com.mrcrayfish.controllable.client.Buttons; import com.mrcrayfish.controllable.client.Controller; import com.mrcrayfish.guns.GunConfig; import com.mrcrayfish.guns.client.render.gun.IOverrideModel; @@ -37,7 +38,7 @@ public void tick(EntityLivingBase entity) Controller controller = Controllable.getController(); if(controller != null) { - shooting |= controller.getState().rightTrigger >= 0.5; + shooting |= controller.isButtonPressed(Buttons.RIGHT_TRIGGER); } } diff --git a/src/main/java/com/mrcrayfish/guns/proxy/ClientProxy.java b/src/main/java/com/mrcrayfish/guns/proxy/ClientProxy.java index 0934bf2f0..e1ed8e54c 100644 --- a/src/main/java/com/mrcrayfish/guns/proxy/ClientProxy.java +++ b/src/main/java/com/mrcrayfish/guns/proxy/ClientProxy.java @@ -1,6 +1,7 @@ package com.mrcrayfish.guns.proxy; import com.mrcrayfish.controllable.Controllable; +import com.mrcrayfish.controllable.client.Buttons; import com.mrcrayfish.controllable.client.Controller; import com.mrcrayfish.guns.GunConfig; import com.mrcrayfish.guns.client.ControllerEvents; @@ -209,7 +210,7 @@ public boolean isZooming() Controller controller = Controllable.getController(); if(controller != null) { - zooming |= controller.getLTriggerValue() >= 0.5; + zooming |= controller.isButtonPressed(Buttons.LEFT_TRIGGER); } } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index c067b5bd5..9b8f2dab4 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "cgm", "name": "MrCrayfish's Gun Mod", "description": "Adds Guns in Minecraft. Created as a part of MrCrayfish's Mod Week", - "version": "0.15.2", + "version": "0.15.3", "mcversion": "1.12.2", "url": "", "updateUrl": "",