Jump to content

Import problem in intellij


Seawarrior

Recommended Posts

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
    }

}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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