Java Code Examples for net.minecraft.init.Items#skull()

The following examples show how to use net.minecraft.init.Items#skull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FireworkRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private void loadAllFireworks() {
    //charges
    Item[] shapes = new Item[]{null, Items.fire_charge, Items.gold_nugget, Items.feather, Items.skull};
    Item[] effects = new Item[]{null, Items.diamond, Items.glowstone_dust};
    for (Item shape : shapes)
        for (Item effect : effects)
            genRecipe(Items.gunpowder, shape, effect, Items.dye, Items.dye, 0);

    //fireworks
    genRecipe(Items.gunpowder, Items.paper, Items.firework_charge, 2);
    genRecipe(Items.gunpowder, Items.gunpowder, Items.paper, Items.firework_charge, 2);
    genRecipe(Items.gunpowder, Items.gunpowder, Items.gunpowder, Items.paper, Items.firework_charge, 2);

    //setup a valid charge to use for the recolour recipe
    for (int i = 0; i < 9; i++)
        inventoryCrafting.setInventorySlotContents(i, null);
    inventoryCrafting.setInventorySlotContents(0, new ItemStack(Items.gunpowder));
    inventoryCrafting.setInventorySlotContents(1, new ItemStack(Items.dye));
    recipeFireworks.matches(inventoryCrafting, null);
    ItemStack charge = recipeFireworks.getCraftingResult(null);
    genRecipe(charge, Items.dye, Items.dye, 1);
}
 
Example 2
Source File: PlayerListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * This blocks interaction with Ember Rods on your island, to avoid blowing up chests, and placing enchanted items
 * such as enchanted gold blocks.
 */
@SubscribeEvent()
public void onInteract(PlayerInteractEvent e) {
    Minecraft mc = Minecraft.getMinecraft();
    ItemStack heldItem = e.entityPlayer.getHeldItem();

    if (main.getUtils().isOnSkyblock() && e.entityPlayer == mc.thePlayer && heldItem != null) {
        if (heldItem.getItem() == Items.skull) {
            Backpack backpack = BackpackManager.getFromItem(heldItem);
            if (backpack != null) {
                BackpackManager.setOpenedBackpackColor(backpack.getBackpackColor());
            }
        }

        // Update fishing status
        if (heldItem.getItem().equals(Items.fishing_rod)
                && (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK || e.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR)) {
            if (main.getConfigValues().isEnabled(Feature.FISHING_SOUND_INDICATOR)) {
                oldBobberIsInWater = false;
                lastBobberEnteredWater = Long.MAX_VALUE;
                oldBobberPosY = 0;
            }
            if (main.getConfigValues().isEnabled(Feature.SHOW_ITEM_COOLDOWNS) && mc.thePlayer.fishEntity != null) {
                CooldownManager.put(mc.thePlayer.getHeldItem());
            }
        } else if (EnchantedItemBlacklist.shouldBlockUsage(heldItem, e.action)) {
            e.setCanceled(true);
        }
    }
}
 
Example 3
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderByItem(ItemStack itemStackIn) {
    if(itemStackIn.getItem() == Items.banner) {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }else if(itemStackIn.getItem() == Items.skull) {
        GameProfile gameprofile = null;

        if(itemStackIn.hasTagCompound()) {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }else{
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if(block == Blocks.ender_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block == Blocks.trapped_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block != Blocks.chest)
            net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
        else{
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
Example 4
Source File: MixinTileEntityItemStackRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void renderByItem(ItemStack itemStackIn) {
    if(itemStackIn.getItem() == Items.banner) {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }else if(itemStackIn.getItem() == Items.skull) {
        GameProfile gameprofile = null;

        if(itemStackIn.hasTagCompound()) {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            try {
                if(nbttagcompound.hasKey("SkullOwner", 10)) {
                    gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
                }else if(nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0) {
                    GameProfile lvt_2_2_ = new GameProfile(null, nbttagcompound.getString("SkullOwner"));
                    gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                    nbttagcompound.removeTag("SkullOwner");
                    nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
                }
            }catch(Exception ignored) {
            }
        }

        if(TileEntitySkullRenderer.instance != null) {
            GlStateManager.pushMatrix();
            GlStateManager.translate(-0.5F, 0.0F, -0.5F);
            GlStateManager.scale(2.0F, 2.0F, 2.0F);
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }else{
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if(block == Blocks.ender_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }else if(block == Blocks.trapped_chest) {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F);
        }else{
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
Example 5
Source File: SkullFireSwordDropFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent( priority = EventPriority.LOWEST )
public void onLivingDrops( LivingDropsEvent event )
{
  try
  {
    if( mSkullFireSword == null ) {
        return;
    }

    // MainRegistry.Logger.info( "SkullFireSwordDropFix::onLivingDrops" );
    if( event.recentlyHit && isValidSkeletonEntity( event.entityLiving ) && event.source.getEntity() instanceof EntityPlayer)
    {
      EntityPlayer player = (EntityPlayer) event.source.getEntity();
      if( player.getHeldItem() != null && player.getHeldItem().getItem() == mSkullFireSword.getItem())
      {
        // MainRegistry.Logger.info( "SkullFireSwordDropFix::Perform DropAction" );

        if( event.drops.isEmpty() ) {
            dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
        } else
        {
          int skulls = 0;
          for( int i = 0; i < event.drops.size(); i++ )
          {
            EntityItem drop = event.drops.get( i );
            ItemStack stack = drop.getEntityItem();
            if( stack.getItem() == Items.skull )
            {
              if( stack.getItemDamage() == 1 ) {
                  dropWitherHeadsInWorld(event, new ItemStack(Items.skull, skulls + 1, 1));
              } else if( stack.getItemDamage() == 0 ) {
                  dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
              }
            }
          }
          if( skulls == 0 ) {
              dropWitherHeadsInWorld(event, new ItemStack(Items.skull, 1, 1));
          }
        }
      }
    }
  }
  catch( Exception e )
  {
    e.printStackTrace();
  }
}
 
Example 6
Source File: EntityArmourStand.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public boolean interact(EntityPlayer player, Vec3 hitPos) {
	if (!worldObj.isRemote) {
		byte b0 = 0;
		ItemStack itemstack = player.getCurrentEquippedItem();
		boolean flag = itemstack != null;

		if (flag && itemstack.getItem() instanceof ItemArmor) {
			ItemArmor itemarmor = (ItemArmor) itemstack.getItem();

			if (itemarmor.armorType == 3)
				b0 = 1;
			else if (itemarmor.armorType == 2)
				b0 = 2;
			else if (itemarmor.armorType == 1)
				b0 = 3;
			else if (itemarmor.armorType == 0)
				b0 = 4;
		}

		if (flag && (itemstack.getItem() == Items.skull || itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)))
			b0 = 4;

		byte b1 = 0;
		boolean isSmall = isSmall();
		double d3 = isSmall ? hitPos.yCoord * 2.0D : hitPos.yCoord;

		if (d3 >= 0.1D && d3 < 0.1D + (isSmall ? 0.8D : 0.45D) && getEquipmentInSlot(1) != null)
			b1 = 1;
		else if (d3 >= 0.9D + (isSmall ? 0.3D : 0.0D) && d3 < 0.9D + (isSmall ? 1.0D : 0.7D) && getEquipmentInSlot(3) != null)
			b1 = 3;
		else if (d3 >= 0.4D && d3 < 0.4D + (isSmall ? 1.0D : 0.8D) && getEquipmentInSlot(2) != null)
			b1 = 2;
		else if (d3 >= 1.6D && getEquipmentInSlot(4) != null)
			b1 = 4;

		boolean flag2 = getEquipmentInSlot(b1) != null;

		if (flag && b0 == 0 && !getShowArms())
			return true;
		else {
			if (flag)
				func_175422_a(player, b0);
			else if (flag2)
				func_175422_a(player, b1);

			return true;
		}
	} else
		return true;
}
 
Example 7
Source File: EtFuturum.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public Item getTabIconItem() {
	return enablePrismarine ? ModItems.prismarine_shard : Items.skull;
}