Revisions for ⁨Burstie Code⁩

View the changes made to this paste.

unlisted ⁨1⁩ ⁨file⁩ 2022-02-09 04:18:37 UTC

BurstShootingEvent.java

@@ -0,0 +1,44 @@

[email protected](modid = MoGuns.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
+public class BurstShootingEvent {
+
+	public static int BURST = 0;
+
+	@SubscribeEvent
+    public static void onKeyPressed(InputEvent.RawMouseEvent event) {
+
+        Minecraft mc = Minecraft.getInstance();
+        PlayerEntity player = mc.player;
+        if(player == null)
+            return;
+
+        ItemStack heldItem = player.getHeldItemMainhand();
+        if(heldItem.getItem() instanceof BurstGunItem) {
+
+            int BUTTON = event.getButton();
+            if(event.getAction() == GLFW.GLFW_PRESS && BUTTON == GLFW.GLFW_MOUSE_BUTTON_LEFT)
+                BURST = 0;
+
+        }
+
+    }
+
+    @SubscribeEvent
+    public static void preShoot(Pre event) {
+
+        if(!(event.getStack().getItem() instanceof BurstGunItem))
+            return;
+
+        if(BURST > 5)
+            event.setCanceled(true);
+
+    }
+
+    @SubscribeEvent
+    public static void postShoot(Post event) {
+
+    	if(BURST <= 5)
+            ++BURST;
+
+    }
+
+}
\ No newline at end of file