Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Seawarrior

Members
  • Joined

  • Last visited

  1. okay only works with static method so how can i do that ?
  2. i annotated with SubscribeEvent look at the code
  3. 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); } }
  4. i tried to refresh the gradle but nothing changed
  5. it's a modern version of forge, so i just can remove the imports or refreshing the gradle ? and how i can do that ?
  6. hi, i'm new in modding and i have a problem, as you can see below the packages and classes : entity, item, sound, ActionResult, Hand, TypedActionResult and World aren't working... they appear in red. if someone have a solution i take ! thx package com.seawarrior.trueguns.item; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.thrown.SnowballEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; public class HK416Item extends Item { private int magAmmo = 30; // magazine ammo capacity private int reloadTime = 50; // reload time in ticks public HK416Item(Settings settings) { super(settings); } @Override public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { if(player.isSneaking()) { // reload startReloading(player); return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand)); } else if(player.getMainHandStack().getMaxDamage() - player.getMainHandStack().getDamage() >= 1) { if(player.getCooldownPeriod() == 0) { fire(world, player); // shoot player.getCooldownPeriodMap().putCooldown(this, 3); // limit fire rate } } return new TypedActionResult<>(ActionResult.PASS, player.getStackInHand(hand)); } private void fire(World world, PlayerEntity player) { // spawn and shoot bullet SnowballEntity bullet = new SnowballEntity(world, player); bullet.setVelocity(player.getRotationVector().multiply(2)); world.spawnEntity(bullet); player.getMainHandStack().damage(1, player, null); world.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENTITY_SNOWBALL_THROW, player.getSoundCategory(), 1, 1); } private void startReloading(PlayerEntity player) { // start reload process } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.