本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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;
}