@Override public boolean matches(IItemStack item) { ItemStack internal = getItemStack(item); return internal != null && stack != null && internal.getItem() == stack.getItem() && (wildcardSize || internal.getCount() >= stack.getCount()) && (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack.getItemDamage() == internal.getItemDamage() || (!stack.getHasSubtypes() && !stack.getItem().isDamageable())); }
@Override public IItemStack withDamage(int damage) { if (stack.getItem().getHasSubtypes()) { MineTweakerAPI.logWarning("subitems don't have damaged states"); return this; } else { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), damage); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); } }
@Override public IIngredient anyDamage() { if (stack.getItem().getHasSubtypes()) { MineTweakerAPI.logWarning("subitems don't have damaged states"); return this; } else { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), OreDictionary.WILDCARD_VALUE); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); } }
@Override public List<IOreDictEntry> getOres() { List<IOreDictEntry> result = new ArrayList<>(); for (String key : OreDictionary.getOreNames()) { for (ItemStack is : OreDictionary.getOres(key)) { if (is.getItem() == stack.getItem() && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE || is.getItemDamage() == stack.getItemDamage())) { result.add(MineTweakerAPI.oreDict.get(key)); break; } } } return result; }
@Override public IItemStack withTag(IData tag) { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage()); if (tag == null) { result.setTagCompound(null); } else { result.setTagCompound((NBTTagCompound) NBTConverter.from(tag)); } return new MCItemStack(result, tag); }
@Override public IBlock asBlock() { ResourceLocation name = Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem())); if (Block.REGISTRY.containsKey(name)) { return new MCItemBlock(stack); } else { throw new ClassCastException("This item is not a block"); } }
@Override public int hashCode() { int hash = 7; hash = 41 * hash + stack.getItem().hashCode(); hash = 41 * hash + stack.getItemDamage(); hash = 41 * hash + stack.getCount(); hash = 41 * hash + (stack.getTagCompound() == null ? 0 : stack.getTagCompound().hashCode()); hash = 41 * hash + (this.wildcardSize ? 1 : 0); return hash; }
public void setItemInUse(ItemStack itemstack, int i) { super.setItemInUse(itemstack, i); if (itemstack != null && itemstack.getItem() != null && itemstack.getItem().getAction(itemstack) == EnumAction.eat) { EntityTracker entitytracker = mcServer.getEntityTracker(dimension); entitytracker.sendPacketToTrackedPlayersAndTrackedEntity( this, new Packet18Animation(this, 5)); } }
@Override public IItemStack removeTag(String tag) { ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage()); if (tag == null) { result.setTagCompound(null); } else { result.getTagCompound().removeTag(tag); } IData dataTag = NBTConverter.from(result.getTagCompound(), false); return new MCItemStack(result, dataTag); }
@Override public ILiquidStack getLiquid() { if (stack.getItem() instanceof ItemFluidContainer) { return new MCLiquidStack( stack .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) .getTankProperties()[0] .getContents()); } // FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack); return null; }
private int getFuelTime(ItemStack item) { if (item == null) { return 0; } // CUSTOM FUEL HERE // Lava should melt 128 items, not 100 if (Item.getId(item.getItem()) == org.bukkit.Material.LAVA_BUCKET.getId()) { return 25600; } else { return fuelTime(item); } }
public boolean a(EntityHuman entityhuman) { ItemStack itemstack = entityhuman.inventory.getItemInHand(); boolean flag = itemstack != null && itemstack.getItem() == Items.MONSTER_EGG; if (!flag && isAlive() && !ca() && !isBaby()) { if (!world.isStatic) { a_(entityhuman); entityhuman.openTrade(this, getCustomName()); } return true; } else { return super.a(entityhuman); } }
public int getItemIcon(ItemStack itemstack, int i) { int j = super.getItemIcon(itemstack, i); if (itemstack.itemID == Item.fishingRod.shiftedIndex && fishEntity != null) { j = itemstack.getIconIndex() + 16; } else { if (itemstack.getItem().func_46058_c()) { return itemstack.getItem().func_46057_a(itemstack.getItemDamage(), i); } if (itemInUse != null && itemstack.itemID == Item.bow.shiftedIndex) { int k = itemstack.getMaxItemUseDuration() - itemInUseCount; if (k >= 18) { return 133; } if (k > 13) { return 117; } if (k > 0) { return 101; } } } return j; }
@Override public boolean matchesExact(IItemStack item) { ItemStack internal = getItemStack(item); if (internal.getTagCompound() != null && stack.getTagCompound() == null) { return false; } if (internal.getTagCompound() == null && stack.getTagCompound() != null) { return false; } if (internal.getTagCompound() == null && stack.getTagCompound() == null) { return stack.getItem() == internal.getItem() && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata()); } if (internal.getTagCompound().getKeySet().equals(stack.getTagCompound().getKeySet())) { for (String s : internal.getTagCompound().getKeySet()) { if (!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) { return false; } } } return stack.getItem() == internal.getItem() && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata()); }
private static void writeWatchableObject( DataOutputStream par0DataOutputStream, WatchableObject par1WatchableObject) throws IOException { int i = (par1WatchableObject.getObjectType() << 5 | par1WatchableObject.getDataValueId() & 0x1f) & 0xff; par0DataOutputStream.writeByte(i); switch (par1WatchableObject.getObjectType()) { case 0: par0DataOutputStream.writeByte(((Byte) par1WatchableObject.getObject()).byteValue()); break; case 1: par0DataOutputStream.writeShort(((Short) par1WatchableObject.getObject()).shortValue()); break; case 2: par0DataOutputStream.writeInt(((Integer) par1WatchableObject.getObject()).intValue()); break; case 3: par0DataOutputStream.writeFloat(((Float) par1WatchableObject.getObject()).floatValue()); break; case 4: Packet.writeString((String) par1WatchableObject.getObject(), par0DataOutputStream); break; case 5: ItemStack itemstack = (ItemStack) par1WatchableObject.getObject(); par0DataOutputStream.writeShort(itemstack.getItem().shiftedIndex); par0DataOutputStream.writeByte(itemstack.stackSize); par0DataOutputStream.writeShort(itemstack.getItemDamage()); break; case 6: ChunkCoordinates chunkcoordinates = (ChunkCoordinates) par1WatchableObject.getObject(); par0DataOutputStream.writeInt(chunkcoordinates.posX); par0DataOutputStream.writeInt(chunkcoordinates.posY); par0DataOutputStream.writeInt(chunkcoordinates.posZ); break; } }
protected void func_35201_a(ItemStack itemstack, int i) { if (itemstack.getItemUseAction() == EnumAction.drink) { worldObj.playSoundAtEntity( this, "random.drink", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (itemstack.getItemUseAction() == EnumAction.eat) { for (int j = 0; j < i; j++) { Vec3D vec3d = Vec3D.createVector( ((double) rand.nextFloat() - 0.5D) * 0.10000000000000001D, Math.random() * 0.10000000000000001D + 0.10000000000000001D, 0.0D); vec3d.rotateAroundX((-rotationPitch * 3.141593F) / 180F); vec3d.rotateAroundY((-rotationYaw * 3.141593F) / 180F); Vec3D vec3d1 = Vec3D.createVector( ((double) rand.nextFloat() - 0.5D) * 0.29999999999999999D, (double) (-rand.nextFloat()) * 0.59999999999999998D - 0.29999999999999999D, 0.59999999999999998D); vec3d1.rotateAroundX((-rotationPitch * 3.141593F) / 180F); vec3d1.rotateAroundY((-rotationYaw * 3.141593F) / 180F); vec3d1 = vec3d1.addVector(posX, posY + (double) getEyeHeight(), posZ); worldObj.spawnParticle( (new StringBuilder()) .append("iconcrack_") .append(itemstack.getItem().shiftedIndex) .toString(), vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.050000000000000003D, vec3d.zCoord); } worldObj.playSoundAtEntity( this, "random.eat", 0.5F + 0.5F * (float) rand.nextInt(2), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); } }
@Override public String toString() { StringBuilder result = new StringBuilder(); result.append('<'); result.append(Item.REGISTRY.getNameForObject(stack.getItem())); if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { result.append(":*"); } else if (stack.getItemDamage() > 0) { result.append(':').append(stack.getItemDamage()); } result.append('>'); if (stack.getTagCompound() != null) { result.append(".withTag("); result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString()); result.append(")"); } return result.toString(); }
@Override public IItemStack withAmount(int amount) { ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage()); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag); }
@Override public IItemDefinition getDefinition() { return new MCItemDefinition( Item.REGISTRY.getNameForObject(stack.getItem()).toString(), stack.getItem()); }
@Override public float getBlockHardness() { return ReflectionHelper.getPrivateValue( Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness"); }
@Override public IItemStack anyAmount() { ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage()); result.setTagCompound(stack.getTagCompound()); return new MCItemStack(result, tag, true); }