Posted October 22, 20231 yr in the following code, references isButtonDown and isKeyDown aren't working... please help me ! thx package com.seawarrior.trueguns.item; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber @Mod("hk416item") public class HK416Item extends Item implements IHK416Item { public HK416Item(Properties properties) { super(properties); } boolean LeftClick = false; boolean rKeyPressed = false; @SubscribeEvent public void onMouseInput(InputEvent.MouseInputEvent event) { if(event.getButton() == 0 && event.isButtonDown()) { LeftClick = true; } } @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(event.getKey() == InputConstants.KEY_R && event.isKeyDown()) { rKeyPressed = true; } } @Override public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) { if(LeftClick) { // Logique clic gauche LeftClick = false; } if(rKeyPressed) { // Logique touche R rKeyPressed = false; } return InteractionResultHolder.consume(player.getItemInHand(hand)); } private void zoom(Player player, double zoomFactor) { // Zoom logic } private void fire(Level world, Player player) { // Fire logic } // Variables cadence de tir private final int fireRate = 15; private int timeSinceLastShot = 0; // Rechargement private final int magAmmo = 30; private int reloadTime = 50; // Zoom private final double zoomFactor = 2.0; @Override public void onStoppedUsing(ItemStack stack, Level world, LivingEntity user, int remainingUseTicks, Player player) { timeSinceLastShot = 0; zoom(player, 1.0); } }
October 24, 20231 yr The EventBusSubscriber annotation only works for static methods annotated with SubscribeEvent Official Forge Discord server | Support FAQ for players
October 28, 20231 yr 9 hours ago, Seawarrior said: i annotated with SubscribeEvent look at the code Read Paint_Ninja's message again, there's an additional requirement that you're not meeting. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 28, 20231 yr Do you know basic java? Tutorial about the keyword static in java: https://www.baeldung.com/java-static
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.