本文整理匯總了Java中net.minecraft.item.ItemTool類的典型用法代碼示例。如果您正苦於以下問題:Java ItemTool類的具體用法?Java ItemTool怎麽用?Java ItemTool使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ItemTool類屬於net.minecraft.item包,在下文中一共展示了ItemTool類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: render
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public void render(@Nonnull ItemStack droneHeldItem) {
EntityItem carriedItem = new EntityItem(world);
carriedItem.hoverStart = 0.0F;
carriedItem.setItem(droneHeldItem);
double scaleFactor = carriedItem.getItem().getItem() instanceof ItemBlock ? 0.7F : 0.5F;
double yOffset = -0.2F;
if (carriedItem.getItem().getItem() instanceof ItemTool || carriedItem.getItem().getItem() instanceof ItemSword) {
// since items are rendered suspended under the drone,
// holding tools upside down looks more natural - especially if the drone is digging with them
GlStateManager.rotate(180, 1, 0, 0);
}
GlStateManager.translate(0, yOffset, 0);
GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor);
customRenderItem.doRender(carriedItem, 0, 0, 0, 0, 0);
}
示例2: instanceOf
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public boolean instanceOf(IItemType type) {
if (type.equals(IItemType.ItemFishingRod)) {
return item instanceof ItemFishingRod;
} else if (type.equals(IItemType.ItemPotion)) {
return item instanceof ItemPotion;
} else if (type.equals(IItemType.ItemFood)) {
return item instanceof ItemFood;
} else if (type.equals(IItemType.ItemSword)) {
return item instanceof ItemSword;
} else if (type.equals(IItemType.ItemTool)) {
return item instanceof ItemTool;
} else if (type.equals(IItemType.ItemNameTag)) {
return item instanceof ItemNameTag;
} else if (type.equals(IItemType.ItemBlock)) {
return item instanceof ItemBlock;
} else if (type.equals(IItemType.ItemHoe)) {
return item instanceof ItemHoe;
}
return false;
}
示例3: matches
import net.minecraft.item.ItemTool; //導入依賴的package包/類
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int australium = 0;
ItemStack stack2 = ItemStack.EMPTY;
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack stack = inv.getStackInSlot(x);
if (!stack.isEmpty())
if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 2) {
if (australium < 8)
australium++;
else
return false;
} else if (stack2.isEmpty() && (stack.getItem() instanceof ItemTool
|| stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow
|| stack.getItem() instanceof ItemUsable || stack.getItem() instanceof ItemCloak))
stack2 = stack;
else
return false;
}
// System.out.println("matches "+(australium&&stack2!=null));
return australium == 8 && !stack2.isEmpty();
}
示例4: canTreecapitate
import net.minecraft.item.ItemTool; //導入依賴的package包/類
/** Can the player treecapitate based on the block selected? */
private boolean canTreecapitate(EntityPlayerMP player, BlockPos pos, IBlockState blockState) {
// can't harvest blacklisted mods and logs
if(HarvestConfig.modLogBlacklist.contains(blockState.getBlock().getRegistryName().getResourceDomain())) return false;
if(HarvestConfig.logBlacklist.contains(blockState.getBlock().getRegistryName().toString())) return false;
// make sure the tool is a valid axe and such
ItemStack heldStack = player.getHeldItemMainhand();
if(heldStack != null && heldStack.getItem() instanceof ItemTool && playerSneakModeValid(player)) {
ItemTool tool = (ItemTool)heldStack.getItem();
for(String tc : tool.getToolClasses(heldStack)) {
if(tc.equals("axe")) {
// now iterate through the drops to make sure the block is an oredict log
for(ItemStack s : blockState.getBlock().getDrops(player.worldObj, pos, blockState, 0)) {
for(int id : OreDictionary.getOreIDs(s)) {
if(OreDictionary.getOreName(id).equals("logWood")) {
return true;
}
}
}
}
}
}
return false;
}
示例5: onBlockDestroyedByPlayer
import net.minecraft.item.ItemTool; //導入依賴的package包/類
@Override
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state) {
EntityPlayer player = worldIn.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 10.0d, false);
try {
if (!player.capabilities.isCreativeMode) {
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemTool) {
} else
this.trigger(worldIn, pos, state.withProperty(EXPLODE, true));
}
}
catch (Exception e) {
try {
if (!player.capabilities.isCreativeMode)
this.trigger(worldIn, pos, state.withProperty(EXPLODE, true));
}
catch (Exception e2) {
LogHelper.error(e2 + ": This is caused by an unrelated mod. Under normal conditions, this wont happen.");
this.trigger(worldIn, pos, state.withProperty(EXPLODE, true));
}
}
}
示例6: isBlazonium
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public boolean isBlazonium(EntityPlayer player){
ItemStack item=player.getHeldItemMainhand();
if(item==null)
return false;
if(item.getItem()instanceof ItemTool){
if(((ItemTool)(item.getItem())).getToolMaterial()==ToolMaterials.Blazonium)
return true;
}
if(item.getItem()instanceof ItemSword){
if(((ItemSword)(item.getItem())).getToolMaterialName().equals("Blazonium"))
return true;
}
if(item.getItem()instanceof ItemHoe){
if(((ItemHoe)(item.getItem())).getMaterialName().equals("Blazonium"))
return true;
}
return false;
}
示例7: isEmerald
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public boolean isEmerald(EntityPlayer player){
ItemStack item=player.getHeldItemMainhand();
if(item==null)
return false;
if(item.getItem()instanceof ItemTool){
if(((ItemTool)(item.getItem())).getToolMaterial()==ToolMaterials.Emerald)
return true;
}
if(item.getItem()instanceof ItemSword){
if(((ItemSword)(item.getItem())).getToolMaterialName().equals("Emerald"))
return true;
}
if(item.getItem()instanceof ItemHoe){
if(((ItemHoe)(item.getItem())).getMaterialName().equals("Emerald"))
return true;
}
return false;
}
示例8: nerfStandardRecipes
import net.minecraft.item.ItemTool; //導入依賴的package包/類
@Override
protected void nerfStandardRecipes ()
{
for (Item item : (Iterable<Item>) GameData.getItemRegistry())
{
if ((item instanceof ItemTool || item instanceof ItemSword) && !isBBTool(item))
{
String repairMaterial = BetterBeginningsHandler.getToolRepairMaterial(item);
if (!Strings.isNullOrEmpty(repairMaterial) && !OreDictionary.getOres(repairMaterial).isEmpty())
{
nerfToolRecipe(new ItemStack(item), repairMaterial);
}
}
}
}
示例9: getToolRepairMaterial
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public static String getToolRepairMaterial (final Item tool)
{
for (String oreDictName : OreDictionary.getOreNames())
{
if (!Strings.isNullOrEmpty(oreDictName))
{
for (ItemStack ore : OreDictionary.getOres(oreDictName))
{
if (tool instanceof ItemTool && ((ItemTool) tool).getIsRepairable(new ItemStack(tool), ore))
{
return oreDictName;
}
else if (tool instanceof ItemSword && ((ItemSword) tool).getIsRepairable(new ItemStack(tool), ore))
{
return oreDictName;
}
}
}
}
return StringUtils.EMPTY;
}
示例10: getItemBurnTime
import net.minecraft.item.ItemTool; //導入依賴的package包/類
private int getItemBurnTime(ItemStack stack) {
if (stack == null || stack.stackSize <= 0) {
return 0;
} else {
Item item = stack.getItem();
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab) return 150;
if (block.getMaterial() == Material.wood) return 300;
if (block == Blocks.coal_block) return 16000;
}
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe) item).getMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(stack);
}
}
示例11: getItemBurnTime
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public static int getItemBurnTime(ItemStack stack) {
if (stack == null) {
return 0;
} else {
Item item = stack.getItem();
//If block
if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab) return 150;
if (block.getMaterial() == Material.wood) return 300;
if (block == Blocks.coal_block) return 16000;
}
if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(stack);
}
}
示例12: mineOutEverything
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public void mineOutEverything(int[][] locations, BreakEvent event)
{
EntityPlayer player = event.getPlayer();
ItemStack current = player.getCurrentEquippedItem();
for (int i = 0; i < locations.length; i++)
{
int curX = event.x + locations[i][0];
int curY = event.y + locations[i][1];
int curZ = event.z + locations[i][2];
Block miningBlock = event.world.getBlock(curX, curY, curZ);
int meta = event.world.getBlockMetadata(curX, curY, curZ);
if (canHarvestBlock(player, event.block, miningBlock, meta, curX, curY, curZ))
{
if (!((ItemTool) current.getItem()).onBlockStartBreak(current, curX, curY, curZ, player))
{
mineBlock(event.world, curX, curY, curZ, meta, player, miningBlock);
((ItemTool) current.getItem()).onBlockDestroyed(current, event.world, miningBlock, curX, curY, curZ, player);
player.addExhaustion((float) 0.025);
}
}
}
}
示例13: canHarvestBlock
import net.minecraft.item.ItemTool; //導入依賴的package包/類
private boolean canHarvestBlock(EntityPlayer player, Block origBlock, Block block, int meta, int x, int y, int z)
{
ItemStack current = player.getCurrentEquippedItem();
if (current == null)
return false;
String toolClass = getToolClass(current.getItem().getClass());
if (toolClass == null)
return false;
float hardness = block.getBlockHardness(player.worldObj, x, y, z);
float digSpeed = ((ItemTool) current.getItem()).getDigSpeed(current, block, meta);
// It works. It just does.
return (digSpeed > 1.0F && block.getHarvestLevel(meta) <= ((ItemTool) current.getItem()).getHarvestLevel(current, toolClass) && hardness >= 0 && origBlock
.getBlockHardness(player.worldObj, x, y, z) >= hardness - 1.5);
}
示例14: onTooltip
import net.minecraft.item.ItemTool; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTooltip(ItemTooltipEvent event)
{
ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
ItemStack stack = event.getItemStack();
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (stack != null && nbt != null)
{
if (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemShield || stack.getItem() instanceof ItemTool)
{
Rarity rarity = Rarity.getRarity(nbt);
if (rarity != Rarity.DEFAULT)
{
addTooltips(tooltip, stack, nbt);
}
}
}
}
示例15: getItemBurnTime
import net.minecraft.item.ItemTool; //導入依賴的package包/類
public static int getItemBurnTime(ItemStack itemstack){
if(itemstack == null){
return 0;
}else{
Item item = itemstack.getItem();
if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air){
Block block = Block.getBlockFromItem(item);
if(block == CocoaBlocks.cocoaDryer){
return 200;
}
if(block.getMaterial() == Material.rock){
return 300;
}
}
if(item == Items.coal) return 1600;
if(item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("EMERALD")) return 300;
return GameRegistry.getFuelValue(itemstack);
}
}