net.minecraft.item.ItemSword Java Examples
The following examples show how to use
net.minecraft.item.ItemSword.
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: GuiWeaponSelection.java From Levels with GNU General Public License v2.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override protected void actionPerformed(GuiButton button) throws IOException { EntityPlayerSP player = mc.player; ItemStack stack = player.inventory.getCurrentItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null) { if (Experience.getAttributeTokens(nbt) > 0) { if (stack.getItem() instanceof ItemSword) { for (int i = 0; i < attributes.length; i++) { if (button == attributes[i]) { Levels.network.sendToServer(new PacketAttributeSelection(i)); } } } } } }
Example #2
Source File: GuiWeaponSelection.java From Levels with GNU General Public License v2.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override public void initGui() { EntityPlayer player = this.mc.player; ItemStack stack = player.inventory.getCurrentItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null && stack.getItem() instanceof ItemSword) { attributes = new GuiButton[WeaponAttribute.WEAPON_ATTRIBUTES.size()]; for (int i = 0; i < attributes.length; i++) { attributes[i] = new GuiButton(i, width / 2 - 147, 60 + (i * 20), 75, 20, WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getName(nbt)); this.buttonList.add(attributes[i]); attributes[i].enabled = false; } } }
Example #3
Source File: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 6 votes |
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, BlockPos pos, IBlockState state, EntityPlayerMP player) { Block bBlock = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); BlockBreakEvent bbe = new BlockBreakEvent(bBlock, player.getBukkitEntity()); EntityPlayerMP playermp = player; net.minecraft.block.Block block = state.getBlock(); if (!(playermp instanceof FakePlayer)) { boolean isSwordNoBreak = playermp.interactionManager.getGameType().isCreative() && !playermp.getHeldItemMainhand().isEmpty() && playermp.getHeldItemMainhand().getItem() instanceof ItemSword; if (!isSwordNoBreak) { int exp = 0; if (!(block == null || !player.canHarvestBlock(block.getDefaultState()) || block.canSilkHarvest(world, pos, block.getBlockState().getBaseState(), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0)) { int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand()); exp = block.getExpDrop(state, world, pos, bonusLevel); } bbe.setExpToDrop(exp); } else { bbe.setCancelled(true); } } world.getServer().getPluginManager().callEvent(bbe); return bbe; }
Example #4
Source File: EventTooltip.java From Levels with GNU General Public License v2.0 | 6 votes |
@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); } } } }
Example #5
Source File: TriggerBot.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
@Override public void onTicks() { try { if (Wrapper.INSTANCE.mc().objectMouseOver != null && Wrapper.INSTANCE.mc().objectMouseOver.entityHit != null && this.isValidTarget(Wrapper.INSTANCE.mc().objectMouseOver.entityHit) && TriggerBot.hasReached(150 + rand.nextInt(100))) { if (Criticals.isActive && !Wrapper.INSTANCE.player().isInWater() && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) && Wrapper.INSTANCE.player().onGround) { Wrapper.INSTANCE.player().motionY = 0.1; Wrapper.INSTANCE.player().fallDistance = 0.1f; Wrapper.INSTANCE.player().onGround = false; } if (AutoBlock.isActive && Wrapper.INSTANCE.player().getCurrentEquippedItem() != null && Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword) { ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem(); lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player()); } Wrapper.INSTANCE.player().swingItem(); Wrapper.INSTANCE.mc().playerController.attackEntity(Wrapper.INSTANCE.player(), Wrapper.INSTANCE.mc().objectMouseOver.entityHit); this.reset(); } } catch (Exception ex) { } }
Example #6
Source File: Forcefield.java From ehacks-pro with GNU General Public License v3.0 | 6 votes |
private void hitEntity(Entity e, boolean block, boolean criticals, boolean aimbot, boolean auto) { if (block && Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword) { ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem(); lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player()); } if (criticals && !Wrapper.INSTANCE.player().isInWater() && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) && Wrapper.INSTANCE.player().onGround) { Wrapper.INSTANCE.player().motionY = 0.1000000014901161; Wrapper.INSTANCE.player().fallDistance = 0.1f; Wrapper.INSTANCE.player().onGround = false; } if (aimbot) { AimBot.faceEntity(e); } Wrapper.INSTANCE.mc().playerController.attackEntity(Wrapper.INSTANCE.player(), e); Wrapper.INSTANCE.player().swingItem(); }
Example #7
Source File: CraftEventFactory.java From Thermos with GNU General Public License v3.0 | 6 votes |
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; }
Example #8
Source File: ExtraInventory.java From ForgeHax with MIT License | 6 votes |
private static int getItemValue(ItemStack stack, boolean loopGuard) { Item item = stack.getItem(); if (stack.isEmpty()) { return 0; } else if (item instanceof ItemArmor || item instanceof ItemPickaxe || item instanceof ItemAxe || item instanceof ItemSword || item instanceof ItemFood || item instanceof ItemArrow || Items.TOTEM_OF_UNDYING.equals(item)) { return 100 * stack.getCount(); // very important } else if (item instanceof ItemShulkerBox) { return 5 + (loopGuard ? 0 : Utils.getShulkerContents(stack) .stream() .mapToInt(ExtraInventory::getItemValueSafe) .sum()); } else { return 5; } }
Example #9
Source File: EventSoulBound.java From Levels with GNU General Public License v2.0 | 6 votes |
@SubscribeEvent public void onPlayerDeath(PlayerDropsEvent event) { EntityPlayer player = event.getEntityPlayer(); Item item; for (int i = 0; i < event.getDrops().size(); i++) { item = event.getDrops().get(i).getEntityItem().getItem(); if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow)) { ItemStack stack = event.getDrops().get(i).getEntityItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (nbt != null) { if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt)) { event.getDrops().remove(i); player.inventory.addItemStackToInventory(stack); } } } } }
Example #10
Source File: EventCreateWeapon.java From Levels with GNU General Public License v2.0 | 6 votes |
@SubscribeEvent public void onCreateWeapon(PlayerTickEvent event) { if (!event.player.getEntityWorld().isRemote) { if (event.phase == Phase.START) { for (ItemStack stack : event.player.inventory.mainInventory) { if (stack != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield)) { create(stack, event.player); } } } } }
Example #11
Source File: EventInput.java From Levels with GNU General Public License v2.0 | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void onKeyPress(InputEvent.KeyInputEvent event) { KeyBinding l = ClientProxy.keyBindingL; Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.player; if (player != null) { ItemStack stack = player.inventory.getCurrentItem(); if (stack != null) { Item current = stack.getItem(); if (current != null) { if (current instanceof ItemSword || current instanceof ItemTool || current instanceof ItemArmor || current instanceof ItemBow || current instanceof ItemShield) { if (l.isPressed()) { player.openGui(Levels.instance, GuiHandler.ITEM_INFORMATION, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } } } } } }
Example #12
Source File: GuiWeaponSelection.java From Levels with GNU General Public License v2.0 | 5 votes |
@SideOnly(Side.CLIENT) @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); EntityPlayer player = this.mc.player; ItemStack stack = player.inventory.getCurrentItem(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null && stack.getItem() instanceof ItemSword) { drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes"), width / 2, 20, 0xFFFFFF); drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.tokens") + ": " + Experience.getAttributeTokens(nbt), width / 2 - 112, 40, 0xFFFFFF); drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.current"), width / 2 + 112, 40, 0xFFFFFF); int k = -1; for (int i = 0; i < WeaponAttribute.WEAPON_ATTRIBUTES.size(); i++) { if (WeaponAttribute.WEAPON_ATTRIBUTES.get(i).hasAttribute(nbt)) { k++; drawCenteredString(fontRendererObj, WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 60 + (10 * k), WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getHex()); } } displayButtons(nbt); drawTooltips(nbt, mouseX, mouseY); } }
Example #13
Source File: GuiItemInformation.java From Levels with GNU General Public License v2.0 | 5 votes |
@SideOnly(Side.CLIENT) @Override protected void actionPerformed(GuiButton button) throws IOException { EntityPlayerSP player = mc.player; if (player != null) { ItemStack stack = player.inventory.getCurrentItem(); if (stack != null) { if (button == selection) { if (stack.getItem() instanceof ItemSword) { player.openGui(Levels.instance, GuiHandler.WEAPON_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } else if (stack.getItem() instanceof ItemArmor) { player.openGui(Levels.instance, GuiHandler.ARMOR_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } else if (stack.getItem() instanceof ItemBow) { player.openGui(Levels.instance, GuiHandler.BOW_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } else if (stack.getItem() instanceof ItemShield) { player.openGui(Levels.instance, GuiHandler.SHIELD_ATTRIBUTES, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } else if (stack.getItem() instanceof ItemTool) { //player.openGui(Levels.instance, GuiHandler., player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ); } } } } }
Example #14
Source File: ItemBrainUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleMining(BreakSpeed event) { EntityPlayer p = event.getEntityPlayer(); ItemStack test = new ItemStack(this, 1, 3); if (CyberwareAPI.isCyberwareInstalled(p, test) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(p, test)) && isContextWorking(p) && !p.isSneaking()) { IBlockState state = event.getState(); ItemStack tool = p.getHeldItem(EnumHand.MAIN_HAND); if (tool != null && (tool.getItem() instanceof ItemSword || tool.getItem().getUnlocalizedName().contains("sword"))) return; if (isToolEffective(tool, state)) return; for (int i = 0; i < 10; i++) { if (i != p.inventory.currentItem) { ItemStack potentialTool = p.inventory.mainInventory[i]; if (isToolEffective(potentialTool, state)) { p.inventory.currentItem = i; return; } } } } }
Example #15
Source File: AutoBlock.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@Override public void onTicks() { if (!(KillAura.isActive || MobAura.isActive || ProphuntAura.isActive || Forcefield.isActive || TriggerBot.isActive || !Wrapper.INSTANCE.mcSettings().keyBindAttack.getIsKeyPressed() || Wrapper.INSTANCE.player().getCurrentEquippedItem() == null || !(Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword))) { ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem(); lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player()); } }
Example #16
Source File: KillAura.java From ehacks-pro with GNU General Public License v3.0 | 5 votes |
@Override public void onTicks() { block6: { try { this.currentMS = System.nanoTime() / 900000L; if (!this.hasDelayRun(133L)) { break block6; } for (Object o : Wrapper.INSTANCE.world().loadedEntityList) { EntityPlayer e; if (!(o instanceof EntityPlayer) || (e = (EntityPlayer) o) instanceof EntityPlayerSP || Wrapper.INSTANCE.player().getDistanceToEntity(e) > CheatConfiguration.config.auraradius || e.isDead) { continue; } if (AuraConfiguration.config.friends.contains(e.getCommandSenderName().trim())) { continue; } if (AutoBlock.isActive && Wrapper.INSTANCE.player().getCurrentEquippedItem() != null && Wrapper.INSTANCE.player().getCurrentEquippedItem().getItem() instanceof ItemSword) { ItemStack lel = Wrapper.INSTANCE.player().getCurrentEquippedItem(); lel.useItemRightClick(Wrapper.INSTANCE.world(), Wrapper.INSTANCE.player()); } if (Criticals.isActive && !Wrapper.INSTANCE.player().isInWater() && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.lava) && !Wrapper.INSTANCE.player().isInsideOfMaterial(Material.web) && Wrapper.INSTANCE.player().onGround) { Wrapper.INSTANCE.player().motionY = 0.1000000014901161; Wrapper.INSTANCE.player().fallDistance = 0.1f; Wrapper.INSTANCE.player().onGround = false; } if (AimBot.isActive) { AimBot.faceEntity(e); } Wrapper.INSTANCE.player().setSprinting(false); Wrapper.INSTANCE.player().swingItem(); Wrapper.INSTANCE.mc().playerController.attackEntity(Wrapper.INSTANCE.player(), e); this.lastMS = System.nanoTime() / 900000L; break; } } catch (Exception ex) { } } }
Example #17
Source File: EventAttack.java From Levels with GNU General Public License v2.0 | 4 votes |
/** * Uses rarity bonuses, such as bonus experience or durability bonuses. * @param nbt * @param stack */ private void useRarity(NBTTagCompound nbt, ItemStack stack, boolean death) { Rarity rarity = Rarity.getRarity(nbt); if (rarity != Rarity.DEFAULT) { int var; int var1; int var2; int var3; switch (rarity) { case UNCOMMON: // 6% chance of adding 1-3 experience points; 6% chance of not using durability if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield) || ((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && death)) { var = (int) (Math.random() * 15); var1 = (int) (Math.random() * 3 + 1); if (var == 0) Experience.setExperience(nbt, Experience.getExperience(nbt) + var1); } if (!Config.unlimitedDurability && !death) { var2 = (int) (Math.random() * 15); if (var2 == 0) stack.setItemDamage(stack.getItemDamage() - 1); } break; case RARE: // 10% chance of adding 1-5 experience points; 10% chance of not using durability AND gaining an additional durability point if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield) || ((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && death)) { var = (int) (Math.random() * 10); var1 = (int) (Math.random() * 5 + 1); if (var == 0) Experience.setExperience(nbt, Experience.getExperience(nbt) + var1); } if (!Config.unlimitedDurability && !death) { var2 = (int) (Math.random() * 10); var3 = (int) (Math.random() * 2); if (var2 == 0) stack.setItemDamage(stack.getItemDamage() - (1 + var3)); } break; case LEGENDARY: // 14% chance of adding 3-5 experience points; 14% chance of not using durability AND gaining 1-3 durability points if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield) || ((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && death)) { var = (int) (Math.random() * 7); var1 = (int) (Math.random() * 5 + 3); if (var == 0) Experience.setExperience(nbt, Experience.getExperience(nbt) + var1); } if (!Config.unlimitedDurability && !death) { var2 = (int) (Math.random() * 7); var3 = (int) (Math.random() * 3 + 1); if (var2 == 0) stack.setItemDamage(stack.getItemDamage() - (1 + var3)); } break; case MYTHIC: // 20% chance of adding 3-10 experience points; 20% chance of not using durability AND gaining 1-5 durability points if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemShield) || ((stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemBow) && death)) { var = (int) (Math.random() * 5); var1 = (int) (Math.random() * 8 + 3); if (var == 0) Experience.setExperience(nbt, Experience.getExperience(nbt) + var1); } if (!Config.unlimitedDurability && !death) { var2 = (int) (Math.random() * 5); var3 = (int) (Math.random() * 5 + 1); if (var2 == 0) stack.setItemDamage(stack.getItemDamage() - (1 + var3)); } break; default: break; } } }
Example #18
Source File: ItemSwordMetaProvider.java From OpenPeripheral-Integration with MIT License | 4 votes |
@Override public Object getMeta(ItemSword target, ItemStack stack) { Map<String, Object> result = Maps.newHashMap(); result.put("material", target.getToolMaterialName()); return result; }
Example #19
Source File: TileEntityEnderFurnace.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
/** * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel * @param stack * @return */ private static int getItemBurnTime(ItemStack stack) { if (stack.isEmpty()) { return 0; } int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400; if (burnTime >= 0) { return burnTime; } Item item = stack.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; } if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; } if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; } if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4; } else { if (item == Items.COAL) return COOKTIME_DEFAULT * 12; if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18; if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150; if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4; if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10; // Ender Furnace custom fuels if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9; if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; } if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; } } return 0; }
Example #20
Source File: MixinItemRenderer.java From LiquidBounce with GNU General Public License v3.0 | 4 votes |
/** * @author CCBlueX */ @Overwrite public void renderItemInFirstPerson(float partialTicks) { float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks); AbstractClientPlayer abstractclientplayer = this.mc.thePlayer; float f1 = abstractclientplayer.getSwingProgress(partialTicks); float f2 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks; float f3 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks; this.rotateArroundXAndY(f2, f3); this.setLightMapFromPlayer(abstractclientplayer); this.rotateWithPlayerRotations((EntityPlayerSP) abstractclientplayer, partialTicks); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); if(this.itemToRender != null) { final KillAura killAura = (KillAura) LiquidBounce.moduleManager.getModule(KillAura.class); if(this.itemToRender.getItem() instanceof net.minecraft.item.ItemMap) { this.renderItemMap(abstractclientplayer, f2, f, f1); } else if (abstractclientplayer.getItemInUseCount() > 0 || (itemToRender.getItem() instanceof ItemSword && killAura.getBlockingStatus())) { EnumAction enumaction = killAura.getBlockingStatus() ? EnumAction.BLOCK : this.itemToRender.getItemUseAction(); switch(enumaction) { case NONE: this.transformFirstPersonItem(f, 0.0F); break; case EAT: case DRINK: this.performDrinking(abstractclientplayer, partialTicks); this.transformFirstPersonItem(f, f1); break; case BLOCK: this.transformFirstPersonItem(f + 0.1F, f1); this.doBlockTransformations(); GlStateManager.translate(-0.5F, 0.2F, 0.0F); break; case BOW: this.transformFirstPersonItem(f, f1); this.doBowTransformations(partialTicks, abstractclientplayer); } }else{ if (!LiquidBounce.moduleManager.getModule(SwingAnimation.class).getState()) this.doItemUsedTransformations(f1); this.transformFirstPersonItem(f, f1); } this.renderItem(abstractclientplayer, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON); }else if(!abstractclientplayer.isInvisible()) { this.renderPlayerArm(abstractclientplayer, f, f1); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }
Example #21
Source File: SlotArtifact.java From Artifacts with MIT License | 4 votes |
public boolean isItemValid(ItemStack stack) { return stack.getItem() == ItemArtifact.instance || stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor; }
Example #22
Source File: GuiItemInformation.java From Levels with GNU General Public License v2.0 | 4 votes |
/** * Draws the strings for the ability selection screen. * @param stack * @param abilities * @param nbt */ private void drawStrings(ItemStack stack, NBTTagCompound nbt) { Rarity rarity = Rarity.getRarity(nbt); drawCenteredString(fontRendererObj, stack.getDisplayName(), width / 2, 20, rarity.getHex()); drawString(fontRendererObj, I18n.format("levels.misc.rarity") + ": " + rarity.getName(), width / 2 - 50, 40, rarity.getHex()); drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes"), width / 2, 80, 0xFFFFFF); drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.tokens") + ": " + Experience.getAttributeTokens(nbt), width / 2 - 112, 100, 0xFFFFFF); drawCenteredString(fontRendererObj, I18n.format("levels.misc.attributes.current"), width / 2 + 112, 100, 0xFFFFFF); if (Experience.getLevel(nbt) == Config.maxLevel) { drawString(fontRendererObj, I18n.format("levels.misc.level") + ": " + I18n.format("levels.misc.max"), width / 2 - 50, 50, 0xFFFFFF); drawString(fontRendererObj, I18n.format("levels.misc.experience") + ": " + I18n.format("levels.misc.max"), width / 2 - 50, 60, 0xFFFFFF); } else { drawString(fontRendererObj, I18n.format("levels.misc.level") + ": " + Experience.getLevel(nbt), width / 2 - 50, 50, 0xFFFFFF); drawString(fontRendererObj, I18n.format("levels.misc.experience") + ": " + Experience.getExperience(nbt) + " / " + Experience.getNextLevelExperience(Experience.getLevel(nbt)), width / 2 - 50, 60, 0xFFFFFF); } int k = -1; if (stack.getItem() instanceof ItemSword) { for (int i = 0; i < WeaponAttribute.WEAPON_ATTRIBUTES.size(); i++) { if (WeaponAttribute.WEAPON_ATTRIBUTES.get(i).hasAttribute(nbt)) { k++; drawCenteredString(fontRendererObj, WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), WeaponAttribute.WEAPON_ATTRIBUTES.get(i).getHex()); } } } else if (stack.getItem() instanceof ItemTool) { } else if (stack.getItem() instanceof ItemBow) { for (int i = 0; i < BowAttribute.BOW_ATTRIBUTES.size(); i++) { if (BowAttribute.BOW_ATTRIBUTES.get(i).hasAttribute(nbt)) { k++; drawCenteredString(fontRendererObj, BowAttribute.BOW_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), BowAttribute.BOW_ATTRIBUTES.get(i).getHex()); } } } else if (stack.getItem() instanceof ItemArmor) { for (int i = 0; i < ArmorAttribute.ARMOR_ATTRIBUTES.size(); i++) { if (ArmorAttribute.ARMOR_ATTRIBUTES.get(i).hasAttribute(nbt)) { k++; drawCenteredString(fontRendererObj, ArmorAttribute.ARMOR_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), ArmorAttribute.ARMOR_ATTRIBUTES.get(i).getHex()); } } } else if (stack.getItem() instanceof ItemShield) { for (int i = 0; i < ShieldAttribute.SHIELD_ATTRIBUTES.size(); i++) { if (ShieldAttribute.SHIELD_ATTRIBUTES.get(i).hasAttribute(nbt)) { k++; drawCenteredString(fontRendererObj, ShieldAttribute.SHIELD_ATTRIBUTES.get(i).getName(nbt), width / 2 + 112, 115 + (10 * k), ShieldAttribute.SHIELD_ATTRIBUTES.get(i).getHex()); } } } }
Example #23
Source File: StatSwordsmanship.java From GokiStats with MIT License | 4 votes |
@Override public boolean isItemSupported(ItemStack item) { return super.isItemSupported(item) || item.getItem() instanceof ItemSword; }
Example #24
Source File: ItemMuscleUpgrade.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent public void handleHurt(LivingHurtEvent event) { EntityLivingBase e = event.getEntityLiving(); ItemStack test = new ItemStack(this, 1, 0); int rank = CyberwareAPI.getCyberwareRank(e, test); if (!event.isCanceled() && e instanceof EntityPlayer && (rank > 1) && EnableDisableHelper.isEnabled(CyberwareAPI.getCyberware(e, test)) && getLastBoostSpeed(e)) { EntityPlayer p = (EntityPlayer) e; if (event.getSource() instanceof EntityDamageSource && !(event.getSource() instanceof EntityDamageSourceIndirect)) { EntityDamageSource source = (EntityDamageSource) event.getSource(); Entity attacker = source.getEntity(); int lastAttacked = ReflectionHelper.getPrivateValue(CombatTracker.class, p.getCombatTracker(), 2); if (p.ticksExisted - lastAttacked > 120) { ItemStack weapon = p.getHeldItemMainhand(); int loc = -1; if (weapon != null) { if (p.getItemInUseCount() > 0 || weapon.getItem() instanceof ItemSword || weapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, weapon).containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName())) { loc = p.inventory.currentItem; } } if (loc == -1) { double mostDamage = 0F; for (int i = 0; i < 10; i++) { if (i != p.inventory.currentItem) { ItemStack potentialWeapon = p.inventory.mainInventory[i]; if (potentialWeapon != null) { Multimap<String, AttributeModifier> modifiers = potentialWeapon.getItem().getAttributeModifiers(EntityEquipmentSlot.MAINHAND, potentialWeapon); if (modifiers.containsKey(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName())) { double damage = modifiers.get(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName()).iterator().next().getAmount(); if (damage > mostDamage || loc == -1) { mostDamage = damage; loc = i; } } } } } } if (loc != -1) { //System.out.println("LOC " + loc); p.inventory.currentItem = loc; CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) p); WorldServer world = (WorldServer) p.worldObj; for (EntityPlayer trackingPlayer : world.getEntityTracker().getTrackingPlayers(p)) { CyberwarePacketHandler.INSTANCE.sendTo(new SwitchHeldItemAndRotationPacket(loc, p.getEntityId(), rank > 2 ? attacker.getEntityId() : -1), (EntityPlayerMP) trackingPlayer); } } } } } }
Example #25
Source File: AutoToolHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
public void equipBestTool(BlockPos pos, boolean useSwords, boolean useHands, boolean repairMode) { EntityPlayer player = WMinecraft.getPlayer(); if(player.capabilities.isCreativeMode) return; IBlockState state = BlockUtils.getState(pos); ItemStack heldItem = player.getHeldItemMainhand(); float bestSpeed = getDestroySpeed(heldItem, state); int bestSlot = -1; int fallbackSlot = -1; InventoryPlayer inventory = player.inventory; for(int slot = 0; slot < 9; slot++) { if(slot == inventory.currentItem) continue; ItemStack stack = inventory.getStackInSlot(slot); if(fallbackSlot == -1 && !isDamageable(stack)) fallbackSlot = slot; float speed = getDestroySpeed(stack, state); if(speed <= bestSpeed) continue; if(!useSwords && stack.getItem() instanceof ItemSword) continue; if(isTooDamaged(stack, repairMode)) continue; bestSpeed = speed; bestSlot = slot; } boolean useFallback = isDamageable(heldItem) && (isTooDamaged(heldItem, repairMode) || useHands && getDestroySpeed(heldItem, state) <= 1); if(bestSlot != -1) { inventory.currentItem = bestSlot; return; } if(!useFallback) return; if(fallbackSlot != -1) { inventory.currentItem = fallbackSlot; return; } if(isTooDamaged(heldItem, repairMode)) if(inventory.currentItem == 8) inventory.currentItem = 0; else inventory.currentItem++; }
Example #26
Source File: HyperiumItemRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void renderItemInFirstPerson(float partialTicks, float prevEquippedProgress, float equippedProgress, ItemStack itemToRender) { float f = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks); EntityPlayerSP entityPlayerSP = mc.thePlayer; float f1 = entityPlayerSP.getSwingProgress(partialTicks); float f2 = entityPlayerSP.prevRotationPitch + (entityPlayerSP.rotationPitch - entityPlayerSP.prevRotationPitch) * partialTicks; float f3 = entityPlayerSP.prevRotationYaw + (entityPlayerSP.rotationYaw - entityPlayerSP.prevRotationYaw) * partialTicks; ((IMixinItemRenderer) parent).callRotateArroundXAndY(f2, f3); ((IMixinItemRenderer) parent).callSetLightMapFromPlayer(entityPlayerSP); ((IMixinItemRenderer) parent).callRotateWithPlayerRotations(entityPlayerSP, partialTicks); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); if (itemToRender != null) { if (itemToRender.getItem() == Items.filled_map) { ((IMixinItemRenderer) parent).callRenderItemMap(entityPlayerSP, f2, f, f1); } else if ((itemToRender.getItem() instanceof ItemSword) && !mc.thePlayer.isBlocking() && Settings.CUSTOM_SWORD_ANIMATION) { transformFirstPersonItem(f, f1); } else if (entityPlayerSP.getItemInUseCount() > 0) { EnumAction enumaction = itemToRender.getItemUseAction(); switch (enumaction) { case NONE: transformFirstPersonItem(f, 0.0F); break; case EAT: case DRINK: ((IMixinItemRenderer) parent).callPerformDrinking(entityPlayerSP, partialTicks); if (Settings.OLD_EATING) { transformFirstPersonItem(f, f1); } else { transformFirstPersonItem(f, 0.0F); } break; case BLOCK: if (Settings.OLD_BLOCKHIT) { transformFirstPersonItem(f, f1); ((IMixinItemRenderer) parent).callDoBlockTransformations(); GlStateManager.scale(0.83f, 0.88f, 0.85f); GlStateManager.translate(-0.3f, 0.1f, 0.0f); } else { transformFirstPersonItem(f, 0f); ((IMixinItemRenderer) parent).callDoBlockTransformations(); } break; case BOW: if (Settings.OLD_BOW) { transformFirstPersonItem(f, f1); ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP); GlStateManager.translate(0.0F, 0.1F, -0.15F); } else { transformFirstPersonItem(f, 0.0F); ((IMixinItemRenderer) parent).callDoBowTransformations(partialTicks, entityPlayerSP); } } } else { ((IMixinItemRenderer) parent).callDoItemUsedTransformations(f1); transformFirstPersonItem(f, f1); } parent.renderItem(entityPlayerSP, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON); } else if (!entityPlayerSP.isInvisible()) { ((IMixinItemRenderer) parent).callRenderPlayerArm(entityPlayerSP, f, f1); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }
Example #27
Source File: MixinItemRenderer.java From LiquidBounce with GNU General Public License v3.0 | 4 votes |
/** * @author CCBlueX */ @Overwrite public void renderItemInFirstPerson(float partialTicks) { float f = 1.0F - (this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * partialTicks); AbstractClientPlayer abstractclientplayer = this.mc.thePlayer; float f1 = abstractclientplayer.getSwingProgress(partialTicks); float f2 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks; float f3 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks; this.rotateArroundXAndY(f2, f3); this.setLightMapFromPlayer(abstractclientplayer); this.rotateWithPlayerRotations((EntityPlayerSP) abstractclientplayer, partialTicks); GlStateManager.enableRescaleNormal(); GlStateManager.pushMatrix(); if(this.itemToRender != null) { final KillAura killAura = (KillAura) LiquidBounce.moduleManager.getModule(KillAura.class); if(this.itemToRender.getItem() instanceof net.minecraft.item.ItemMap) { this.renderItemMap(abstractclientplayer, f2, f, f1); } else if (abstractclientplayer.getItemInUseCount() > 0 || (itemToRender.getItem() instanceof ItemSword && killAura.getBlockingStatus())) { EnumAction enumaction = killAura.getBlockingStatus() ? EnumAction.BLOCK : this.itemToRender.getItemUseAction(); switch(enumaction) { case NONE: this.transformFirstPersonItem(f, 0.0F); break; case EAT: case DRINK: this.performDrinking(abstractclientplayer, partialTicks); this.transformFirstPersonItem(f, f1); break; case BLOCK: this.transformFirstPersonItem(f + 0.1F, f1); this.doBlockTransformations(); GlStateManager.translate(-0.5F, 0.2F, 0.0F); break; case BOW: this.transformFirstPersonItem(f, f1); this.doBowTransformations(partialTicks, abstractclientplayer); } }else{ if (!LiquidBounce.moduleManager.getModule(SwingAnimation.class).getState()) this.doItemUsedTransformations(f1); this.transformFirstPersonItem(f, f1); } this.renderItem(abstractclientplayer, this.itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON); }else if(!abstractclientplayer.isInvisible()) { this.renderPlayerArm(abstractclientplayer, f, f1); } GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); RenderHelper.disableStandardItemLighting(); }
Example #28
Source File: TNTBlock.java From LiquidBounce with GNU General Public License v3.0 | 4 votes |
@EventTarget public void onMotionUpdate(MotionEvent event) { for(final Entity entity : mc.theWorld.loadedEntityList) { if(entity instanceof EntityTNTPrimed && mc.thePlayer.getDistanceToEntity(entity) <= rangeValue.get()) { final EntityTNTPrimed tntPrimed = (EntityTNTPrimed) entity; if(tntPrimed.fuse <= fuseValue.get()) { if(autoSwordValue.get()) { int slot = -1; float bestDamage = 1F; for(int i = 0; i < 9; i++) { final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i); if(itemStack != null && itemStack.getItem() instanceof ItemSword) { final float itemDamage = ((ItemSword) itemStack.getItem()).getDamageVsEntity() + 4F; if(itemDamage > bestDamage) { bestDamage = itemDamage; slot = i; } } } if(slot != -1 && slot != mc.thePlayer.inventory.currentItem) { mc.thePlayer.inventory.currentItem = slot; mc.playerController.updateController(); } } if(mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) { mc.gameSettings.keyBindUseItem.pressed = true; blocked = true; } return; } } } if(blocked && !GameSettings.isKeyDown(mc.gameSettings.keyBindUseItem)) { mc.gameSettings.keyBindUseItem.pressed = false; blocked = false; } }