当前位置: 首页>>代码示例>>Java>>正文


Java ItemSword类代码示例

本文整理汇总了Java中net.minecraft.item.ItemSword的典型用法代码示例。如果您正苦于以下问题:Java ItemSword类的具体用法?Java ItemSword怎么用?Java ItemSword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemSword类属于net.minecraft.item包,在下文中一共展示了ItemSword类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLivingAttack

import net.minecraft.item.ItemSword; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
	/*
	 * Player attacks a monster OR another player
	 */
	if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
	{
		EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
		EntityLivingBase enemy = event.getEntityLiving();
		ItemStack stack = player.inventory.getCurrentItem();
		PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
		{
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
			{
				useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:25,代码来源:EventLivingHurtAttack.java

示例2: onItemTooltip

import net.minecraft.item.ItemSword; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemTooltip(ItemTooltipEvent event)
{
	ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
	ItemStack stack = event.getItemStack();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (event.getEntityPlayer() != null)
	{
		PlayerInformation info = (PlayerInformation) event.getEntityPlayer().getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (info != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemLEMagical || stack.getItem() instanceof ItemLEBauble))
		{
			Rarity rarity = Rarity.getRarity(nbt);
			
			if (rarity != Rarity.DEFAULT)
			{
				if (stack.getItem() instanceof ItemSword) drawMelee(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemArmor) drawArmor(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEMagical) drawMagical(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEBauble) drawBauble(tooltip, stack, nbt, event.getEntityPlayer(), info);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:EventItemTooltip.java

示例3: render

import net.minecraft.item.ItemSword; //导入依赖的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);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:RenderDroneHeldItem.java

示例4: callBlockBreakEvent

import net.minecraft.item.ItemSword; //导入依赖的package包/类
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, int x, int y, int z, net.minecraft.block.Block block, int blockMetadata, net.minecraft.entity.player.EntityPlayerMP player)
{
    org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(x, y, z);
    org.bukkit.event.block.BlockBreakEvent blockBreakEvent = new org.bukkit.event.block.BlockBreakEvent(bukkitBlock, ((EntityPlayerMP)player).getBukkitEntity());
    EntityPlayerMP playermp = (EntityPlayerMP)player;
    if (!(playermp instanceof FakePlayer))
    {
        if (!(playermp.theItemInWorldManager.getGameType().isAdventure() && !playermp.isCurrentToolAdventureModeExempt(x, y, z)) && !(playermp.theItemInWorldManager.getGameType().isCreative() && playermp.getHeldItem() != null && playermp.getHeldItem().getItem() instanceof ItemSword))
        {
            int exp = 0;
            if (!(block == null || !player.canHarvestBlock(block) || // Handle empty block or player unable to break block scenario
                    block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player))) // If the block is being silk harvested, the exp dropped is 0
            {
                int meta = block.getDamageValue(world, x, y, z);
                int bonusLevel = EnchantmentHelper.getFortuneModifier(player);
                exp = block.getExpDrop(world, meta, bonusLevel);
            }
            blockBreakEvent.setExpToDrop(exp);
        }
        else blockBreakEvent.setCancelled(true);
    }

    world.getServer().getPluginManager().callEvent(blockBreakEvent);
    return blockBreakEvent;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:26,代码来源:CraftEventFactory.java

示例5: applyBackers

import net.minecraft.item.ItemSword; //导入依赖的package包/类
public static void applyBackers(List<MaterialDefinition> definitions) {
    for (MaterialDefinition definition : definitions) {
        ToolMaterial toolMaterial = definition.getToolMaterial();
        ArmorMaterial armorMaterial = definition.getArmorMaterial();

        RandoresItemData itemData = definition.getData();

        RandoresItems.hoe.registerBacker(itemData, new ItemHoe(toolMaterial));
        RandoresItems.sword.registerBacker(itemData, new ItemSword(toolMaterial));
        RandoresItems.axe.registerBacker(itemData, new ConstructableAxe(toolMaterial, toolMaterial.getDamageVsEntity() + 5f, -3f));
        RandoresItems.shovel.registerBacker(itemData, new ItemSpade(toolMaterial));
        RandoresItems.pickaxe.registerBacker(itemData, new ConstructablePickaxe(toolMaterial));
        RandoresItems.battleaxe.registerBacker(itemData, new ConstructableAxe(toolMaterial, toolMaterial.getDamageVsEntity() + 8f, -3.5f));
        RandoresItems.helmet.registerBacker(itemData, armorMaterial);
        RandoresItems.chestplate.registerBacker(itemData, armorMaterial);
        RandoresItems.leggings.registerBacker(itemData, armorMaterial);
        RandoresItems.boots.registerBacker(itemData, armorMaterial);
    }
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:20,代码来源:MaterialDefinitionGenerator.java

示例6: instanceOf

import net.minecraft.item.ItemSword; //导入依赖的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;
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:21,代码来源:IItem.java

示例7: matches

import net.minecraft.item.ItemSword; //导入依赖的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();
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:24,代码来源:AustraliumRecipe.java

示例8: getUpgradableStack

import net.minecraft.item.ItemSword; //导入依赖的package包/类
/** Gets an upgradeable stack */
public @Nonnull ItemStack getUpgradableStack(@Nonnull List<ItemStack> s) {
	if(ACUtils.doesItemStackListContain(s, upgrade, true)) {
		ItemStack toUpgrade = s.get(0);
		if(enchant.canApply(toUpgrade) && toUpgrade.getItem() instanceof ItemSword) {
			Map<Enchantment, Integer> activeEnchs = EnchantmentHelper.getEnchantments(toUpgrade);
			for(Enchantment i : activeEnchs.keySet()) {
				if(i == enchant) {
					int level = activeEnchs.get(i);
					if(level >= maxLevel) {
						return ItemStack.EMPTY;
					}
				}
			}
			return toUpgrade.copy();
		}
	}
	return ItemStack.EMPTY;
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:20,代码来源:RecipeEnchantmentUpgrade.java

示例9: isSword

import net.minecraft.item.ItemSword; //导入依赖的package包/类
public static boolean isSword(ItemStack stack){
 String[] validWeaponNames = {
	  "sword", "dagger", "sabre", "rapier", "cutlass"	
 };

 if (ItemStackTools.isValid(stack) && stack.getMaxStackSize() == 1)
 {
  Item item = stack.getItem();
  String name = stack.getUnlocalizedName().toLowerCase();
  // Vanilla
  if (item instanceof ItemSword)
  {
	  return true;
  }

  // Just for extra compatibility and/or security and/or less annoyance
  for (String toolName : validWeaponNames)
  {
	  if (name.contains(toolName)) return true;
  }
 }
 return false;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:24,代码来源:ToolUtil.java

示例10: onUse

import net.minecraft.item.ItemSword; //导入依赖的package包/类
@Override
public boolean onUse()
{
	EntityPlayer p;
	
	p = this.player.getPlayer();
	if (p.getCurrentEquippedItem() != null)
	{
		if (p.getCurrentEquippedItem().getItem() instanceof ItemSword)
		{
			PacketSpellToServer packet;
			
			packet = new PacketSpellToServer(getUniqueID());
			Packets.network.sendToServer(packet);
		}
		else
			player.getPlayer().addChatComponentMessage(new ChatComponentText(ChatColor.RED + "You must equip a sword for this." + ChatColor.RESET));
	}
	else
		player.getPlayer().addChatComponentMessage(new ChatComponentText(ChatColor.RED + "You must equip a sword for this." + ChatColor.RESET));
	
	return (true);
}
 
开发者ID:GhostMonk3408,项目名称:MidgarCrusade,代码行数:24,代码来源:Poisonblade_1.java

示例11: PopulateSword

import net.minecraft.item.ItemSword; //导入依赖的package包/类
/**
 * Finds or creates a sword for an ore.
 */
public static void PopulateSword(OreStuff stuff)
{
	if (!stuff.HasSword)
	{
		Item Sword = Util.FindItemFromString(stuff.BaseName + "sword");
		
		if (Sword != null)
		{
			stuff.HasSword = true;
		}
		else
		{
			ItemSword sword = AutoItemAndBlock.CreateSword(stuff.MetalMaterial, ModTabs.maintab, 0, Reference.MODID + ":MissingSwordTexture", stuff.BaseName + "Sword");
			stuff.Sword = sword;
		}
	}
}
 
开发者ID:SneakyTactician,项目名称:BIGB,代码行数:21,代码来源:AutoCreateForOres.java

示例12: isBlazonium

import net.minecraft.item.ItemSword; //导入依赖的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;
}
 
开发者ID:EnderiumSmith,项目名称:Nuclear-Foundation,代码行数:19,代码来源:EventHandler.java

示例13: isEmerald

import net.minecraft.item.ItemSword; //导入依赖的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;
}
 
开发者ID:EnderiumSmith,项目名称:Nuclear-Foundation,代码行数:19,代码来源:EventHandler.java

示例14: nerfStandardRecipes

import net.minecraft.item.ItemSword; //导入依赖的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);
            }
        }
    }
}
 
开发者ID:UndeadZeratul,项目名称:TWBB-Tweaks,代码行数:17,代码来源:ToolRecipeTweaks.java

示例15: getToolRepairMaterial

import net.minecraft.item.ItemSword; //导入依赖的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;
}
 
开发者ID:UndeadZeratul,项目名称:TWBB-Tweaks,代码行数:23,代码来源:BetterBeginningsHandler.java


注:本文中的net.minecraft.item.ItemSword类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。