Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ModItem extends Item {
- public static final String LAYER_KEY = "LayerKey";
- public static int getTag(ItemStack stack, String tag) {
- return stack.getOrCreateTag().getInt(tag);
- }
- public static void setTag(ItemStack stack, String tag, int tagInt) {
- stack.getOrCreateTag().putInt(tag, tagInt);
- }
- public static Float updateModel(ItemStack stack) {
- return (float) stack.getOrCreateTag().getInt(LAYER_KEY);
- }
- public ModItem() {
- super(new Item.Properties().group(ItemGroup.TOOLS));
- }
- @Override
- public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand hand) {
- ItemStack itemStackIn = playerIn.getHeldItem(hand);
- if (!worldIn.isRemote) {
- ModItemEntity modItem = new ModItemEntity(playerIn, worldIn, itemStackIn.copy());
- modItem.shoot(playerIn.getLookVec().x, playerIn.getLookVec().y, playerIn.getLookVec().z, 1.5F, 1.0F);
- worldIn.addEntity(modItem);
- }
- worldIn.playSound(playerIn, playerIn.func_233580_cy_(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (Item.random.nextFloat() * 0.4F + 0.8F));
- return ActionResult.resultSuccess(itemStackIn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement