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.

Featured Replies

Posted

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
    }

}

ย 

In modern versions of Forge you only need to import the Gradle project into your IDE and let it run. If it doesn't, try refreshing Gradle (in IntelliJ this is on the top right Gradle elephant tab, then the refresh button).

For ancient versions you may have to manually run the setupDecompWorkspace task first.

  • Author

it's a modern version of forge, so i just can remove the imports or refreshing the gradle ? and how i can do that ?

ย 

Edited by Seawarrior

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.