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

Alrighty:

 

I've created the model, the item and the required renderers. They all work with each other perfectly. The item also fires an arrow (A starter object that I'm using before upgrading to a custom entity)

 

Images of Gun:

 

The only problem I'm having is that I can not find out how to have the player look as if they're holding the weapon like an actual gun. (Using 1.7.10 Forge btw)

 

I've heard of something called "Enum"? I'm reletively new to Modding in Minecraft (I know basics and some advanced stuff)

 

Here's my code for Item Rifle:

 

[nobbc]import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import net.mcheroesandgenerals.warblocks.*;

public class ItemRifle extends Item
{
  public ItemRifle()
  {
    super();
    this.setFull3D();
    
  }
  
  
  
  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  {
    ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.isCanceled())
    {
        return event.result;
        
    }
  if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.hasItem(WarBlocks.itemRifleAmmo))
      {

      par2World.playSoundAtEntity(par3EntityPlayer, "wb:weapon.rifle.shoot", 1, 1);
      par3EntityPlayer.inventory.consumeInventoryItem(WarBlocks.itemRifleAmmo);
      if (!par2World.isRemote)
         par2World.spawnEntityInWorld(new EntityArrow(par2World, par3EntityPlayer, );
      par2World.spawnParticle("flame", 0, 0, 0, 0.0D, 0.0D, 0.0D);
      }
      return par1ItemStack;
      
  }

  
}[/nobbc]

 

 

 

 

 

  • Author

If you are trying to get the player model to look like it is aiming a bow when using your item you need to put the following in your item class:

 

    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack stack)
    {
        return EnumAction.BOW;
    }

 

This will make the player model "Aim" the item as they would a bow

 

This triggers the player model to raise its arms. At least that is what I deduced while skimming the ModelBiped classes.

 

Let me know if it works

 

Tried that and it didn't work. :\ Not sure why though (Because I HAVE tried that method before). Any other solutions?

Maybe you have to override the Item#getMaxItemUseDuration and Item#onItemRightClick methods? By default the first one is zero and the second one is empty (except for a return).

 

Look in the ItemBow class to see what to add.

Kain

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.