From 51e10eaad2c5c26d72fce405fbf3067666c0c155 Mon Sep 17 00:00:00 2001 From: Nicholas Ignoffo Date: Sun, 1 Jan 2017 22:26:42 -0800 Subject: [PATCH] Everything else except sigils --- .../item/ItemActivationCrystal.java | 3 +- .../bloodmagic/item/ItemAltarMaker.java | 15 ++-- .../bloodmagic/item/ItemArcaneAshes.java | 3 +- .../bloodmagic/item/ItemBloodOrb.java | 18 ++-- .../bloodmagic/item/ItemBloodShard.java | 3 +- .../bloodmagic/item/ItemBoundAxe.java | 9 +- .../bloodmagic/item/ItemBoundPickaxe.java | 10 +-- .../bloodmagic/item/ItemBoundShovel.java | 10 +-- .../bloodmagic/item/ItemBoundSword.java | 12 +-- .../bloodmagic/item/ItemBoundTool.java | 12 +-- .../bloodmagic/item/ItemComponent.java | 5 +- .../item/ItemDaggerOfSacrifice.java | 6 +- .../bloodmagic/item/ItemDemonCrystal.java | 11 +-- .../bloodmagic/item/ItemExperienceBook.java | 5 +- .../bloodmagic/item/ItemInscriptionTool.java | 6 +- .../bloodmagic/item/ItemLavaCrystal.java | 2 +- .../bloodmagic/item/ItemRitualDiviner.java | 32 +++---- .../bloodmagic/item/ItemRitualReader.java | 19 ++-- .../item/ItemSacrificialDagger.java | 17 ++-- .../bloodmagic/item/ItemSanguineBook.java | 17 ++-- .../WayofTime/bloodmagic/item/ItemSlate.java | 3 +- .../item/ItemTelepositionFocus.java | 9 +- .../bloodmagic/item/ItemUpgradeTome.java | 18 ++-- .../bloodmagic/item/ItemUpgradeTrainer.java | 3 +- .../item/alchemy/ItemCuttingFluid.java | 3 +- .../ItemLivingArmourPointsUpgrade.java | 11 +-- .../item/armour/ItemSentientArmour.java | 23 +++-- .../item/block/ItemBlockBloodTank.java | 86 +------------------ .../item/block/base/ItemBlockEnum.java | 2 +- .../item/block/base/ItemBlockString.java | 2 +- .../item/gear/ItemPackSacrifice.java | 7 +- .../item/gear/ItemPackSelfSacrifice.java | 7 +- .../item/inventory/ContainerHolding.java | 26 +++--- .../item/inventory/InventoryHolding.java | 2 +- .../item/inventory/ItemInventory.java | 25 +++--- .../item/routing/ItemNodeRouter.java | 3 +- .../item/routing/ItemRouterFilter.java | 9 +- .../bloodmagic/item/soul/ItemMonsterSoul.java | 3 +- .../item/soul/ItemSentientArmourGem.java | 9 +- .../bloodmagic/item/soul/ItemSentientAxe.java | 32 +++---- .../bloodmagic/item/soul/ItemSentientBow.java | 21 ++--- .../item/soul/ItemSentientPickaxe.java | 31 ++++--- .../item/soul/ItemSentientShovel.java | 32 +++---- .../item/soul/ItemSentientSword.java | 33 ++++--- .../bloodmagic/item/soul/ItemSoulGem.java | 10 +-- .../bloodmagic/item/soul/ItemSoulSnare.java | 18 ++-- 46 files changed, 289 insertions(+), 354 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java index a723262b..13a0a7b1 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemActivationCrystal.java @@ -7,6 +7,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -35,7 +36,7 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java index 74ad1c20..ae9b2aa6 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemAltarMaker.java @@ -57,15 +57,16 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (!player.capabilities.isCreativeMode) { ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.creativeOnly")); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } stack = NBTHelper.checkNBT(stack); @@ -79,12 +80,12 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP setTierToBuild(EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]); ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", NumeralHelper.toRoman(stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1))); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } RayTraceResult rayTrace = rayTrace(world, player, false); if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(rayTrace.getBlockPos()).getBlock() instanceof BlockAltar) { @@ -95,7 +96,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP world.notifyBlockUpdate(rayTrace.getBlockPos(), state, state, 3); } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @@ -132,7 +133,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP public String destroyAltar(EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (world.isRemote) return ""; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java index d2d2d91c..2081305a 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemArcaneAshes.java @@ -43,8 +43,9 @@ public class ItemArcaneAshes extends Item implements IVariantProvider } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); BlockPos newPos = blockPos.offset(side); if (world.isAirBlock(newPos)) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java index 1c2aa67a..39393177 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java @@ -9,6 +9,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -41,42 +42,43 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < OrbRegistry.getSize(); i++) list.add(new ItemStack(id, 1, i)); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world == null) - return super.onItemRightClick(stack, null, player, hand); + return super.onItemRightClick(world, player, hand); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); // SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, // 20, world.provider.getDimensionId(), 4, posX, posY, posZ); if (PlayerHelper.isFakePlayer(player)) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (!stack.hasTagCompound()) { - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } if (Strings.isNullOrEmpty(getOwnerUUID(stack))) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (world.isRemote) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (getOwnerUUID(stack).equals(PlayerHelper.getUsernameFromPlayer(player))) NetworkHelper.setMaxOrb(NetworkHelper.getSoulNetwork(getOwnerUUID(stack)), getOrbLevel(stack.getItemDamage())); NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).add(200, getMaxEssence(stack.getItemDamage())); NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 200); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java index 7a5665f5..ed72887e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodShard.java @@ -6,6 +6,7 @@ import WayofTime.bloodmagic.client.IVariantProvider; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -29,7 +30,7 @@ public class ItemBloodShard extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java index 0521def7..cafe5944 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java @@ -104,9 +104,8 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); - if (itemDrops != null) - for (ItemStack stacks : itemDrops) - drops.add(ItemStackWrapper.getHolder(stacks)); + for (ItemStack stacks : itemDrops) + drops.add(ItemStackWrapper.getHolder(stacks)); } world.setBlockToAir(blockPos); @@ -127,8 +126,8 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 11 : 2, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -3.0, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 11 : 2, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -3.0, 0)); } return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java index 429e905b..c5587491 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java @@ -119,10 +119,8 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider else { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); - - if (itemDrops != null) - for (ItemStack stacks : itemDrops) - drops.add(ItemStackWrapper.getHolder(stacks)); + for (ItemStack stacks : itemDrops) + drops.add(ItemStackWrapper.getHolder(stacks)); } world.setBlockToAir(blockPos); @@ -143,8 +141,8 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 5 : 2, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 5 : 2, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); } return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java index f95b163b..c7f5b9eb 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java @@ -103,10 +103,8 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider else { List itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl); - - if (itemDrops != null) - for (ItemStack stacks : itemDrops) - drops.add(ItemStackWrapper.getHolder(stacks)); + for (ItemStack stacks : itemDrops) + drops.add(ItemStackWrapper.getHolder(stacks)); } world.setBlockToAir(blockPos); @@ -127,8 +125,8 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider Multimap multimap = super.getItemAttributeModifiers(equipmentSlot); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0)); } return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index db1f9223..b8afe2d0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -19,6 +19,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -50,8 +51,9 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); @@ -65,7 +67,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable // return new ActionResult(EnumActionResult.SUCCESS, stack); // } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @@ -88,7 +90,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) + public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList subItems) { subItems.add(Utils.setUnbreakable(new ItemStack(itemIn))); } @@ -115,8 +117,8 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable Multimap multimap = HashMultimap.create(); if (equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 8 : 2, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 8 : 2, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4, 0)); } return multimap; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index 480543a8..b25a0b63 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -28,6 +28,7 @@ import net.minecraft.item.ItemTool; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -80,7 +81,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) + public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList subItems) { subItems.add(Utils.setUnbreakable(new ItemStack(itemIn))); } @@ -125,8 +126,9 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); @@ -140,7 +142,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable return new ActionResult(EnumActionResult.SUCCESS, stack); } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @@ -244,12 +246,12 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable while (count >= maxStackSize) { - world.spawnEntityInWorld(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize))); + world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize))); count -= maxStackSize; } if (count > 0) - world.spawnEntityInWorld(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count))); + world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count))); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java index 95c6dd63..0d4bcaa8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemComponent.java @@ -7,6 +7,7 @@ import lombok.Getter; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -113,7 +114,7 @@ public class ItemComponent extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.size(); i++) list.add(new ItemStack(id, 1, i)); @@ -136,7 +137,7 @@ public class ItemComponent extends Item implements IVariantProvider public static ItemStack getStack(String key, int stackSize) { ItemStack stack = getStack(key); - stack.stackSize = stackSize; + stack.setCount(stackSize); return stack; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java index abdbb755..06ad4c91 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDaggerOfSacrifice.java @@ -37,7 +37,7 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { - if (target == null || attacker == null || attacker.worldObj.isRemote || (attacker instanceof EntityPlayer && !(attacker instanceof EntityPlayerMP))) + if (target == null || attacker == null || attacker.getEntityWorld().isRemote || (attacker instanceof EntityPlayer && !(attacker instanceof EntityPlayerMP))) return false; if (!target.isNonBoss()) @@ -67,9 +67,9 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider lifeEssence = (int) (lifeEssence * (1 + PurificationHelper.getCurrentPurity((EntityAnimal) target))); } - if (PlayerSacrificeHelper.findAndFillAltar(attacker.worldObj, target, lifeEssence, true)) + if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true)) { - target.worldObj.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.worldObj.rand.nextFloat() - target.worldObj.rand.nextFloat()) * 0.8F); + target.getEntityWorld().playSound(null, target.posX, target.posY, target.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.getEntityWorld().rand.nextFloat() - target.getEntityWorld().rand.nextFloat()) * 0.8F); target.setHealth(-1); target.onDeath(BloodMagicAPI.getDamageSource()); } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java index 649bf361..1eb88a7b 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java @@ -7,6 +7,7 @@ import lombok.Getter; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -60,7 +61,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.size(); i++) list.add(new ItemStack(id, 1, i)); @@ -74,18 +75,18 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria @Override public double getWill(ItemStack willStack) { - return getDiscretization(willStack) * willStack.stackSize; + return getDiscretization(willStack) * willStack.getCount(); } @Override public double drainWill(ItemStack willStack, double drainAmount) { double discretization = getDiscretization(willStack); - int drainedNumber = (int) Math.floor(Math.min(willStack.stackSize * discretization, drainAmount) / discretization); + int drainedNumber = (int) Math.floor(Math.min(willStack.getCount() * discretization, drainAmount) / discretization); if (drainedNumber > 0) { - willStack.stackSize -= drainedNumber; + willStack.shrink(drainedNumber); return drainedNumber * discretization; } @@ -101,7 +102,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria @Override public EnumDemonWillType getType(ItemStack willStack) { - return EnumDemonWillType.values()[MathHelper.clamp_int(willStack.getMetadata(), 0, EnumDemonWillType.values().length - 1)]; + return EnumDemonWillType.values()[MathHelper.clamp(willStack.getMetadata(), 0, EnumDemonWillType.values().length - 1)]; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java b/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java index 8d0063f9..7b29b518 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemExperienceBook.java @@ -56,8 +56,9 @@ public class ItemExperienceBook extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (!world.isRemote) { if (player.isSneaking()) @@ -95,7 +96,7 @@ public class ItemExperienceBook extends Item implements IVariantProvider if (player.experienceLevel % 5 == 0) { float f = player.experienceLevel > 30 ? 1.0F : (float) player.experienceLevel / 30.0F; - player.worldObj.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, player.getSoundCategory(), f * 0.75F, 1.0F); + player.getEntityWorld().playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, player.getSoundCategory(), f * 0.75F, 1.0F); } } else { diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java index 2483ab51..e92cf79c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemInscriptionTool.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -45,7 +46,7 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 1; i < EnumRuneType.values().length; i++) { @@ -56,8 +57,9 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); IBlockState state = world.getBlockState(pos); if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack))) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java index 3cd4b88f..d7efd026 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java @@ -34,7 +34,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IFuelHandler, I NetworkHelper.getSoulNetwork(this.getOwnerUUID(itemStack)).syphon(25); ItemStack copiedStack = itemStack.copy(); copiedStack.setItemDamage(copiedStack.getItemDamage()); - copiedStack.stackSize = 1; + copiedStack.setCount(1); return copiedStack; } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java index 3a4154a6..e3170e25 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java @@ -15,11 +15,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -81,15 +77,16 @@ public class ItemRitualDiviner extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); if (player.isSneaking()) { if (world.isRemote) @@ -214,12 +211,11 @@ public class ItemRitualDiviner extends Item implements IVariantProvider return true; } - ItemStack[] inventory = player.inventory.mainInventory; - for (int i = 0; i < inventory.length; i++) + NonNullList inventory = player.inventory.mainInventory; + for (ItemStack newStack : inventory) { - ItemStack newStack = inventory[i]; - if (newStack == null) - { + if (newStack.isEmpty()) { + continue; } Item item = newStack.getItem(); @@ -228,12 +224,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider Block block = ((ItemBlock) item).getBlock(); if (block == ModBlocks.RITUAL_STONE) { - newStack.stackSize--; - if (newStack.stackSize <= 0) - { - inventory[i] = null; - } - + newStack.shrink(1); return true; } } @@ -344,8 +335,9 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); RayTraceResult ray = this.rayTrace(world, player, false); if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { @@ -372,7 +364,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider { EntityPlayer player = (EntityPlayer) entityLiving; - RayTraceResult ray = this.rayTrace(player.worldObj, player, false); + RayTraceResult ray = this.rayTrace(player.getEntityWorld(), player, false); if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { return false; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java index 12ef782b..9aaaed23 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualReader.java @@ -9,10 +9,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentTranslation; @@ -71,8 +68,9 @@ public class ItemRitualReader extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); RayTraceResult ray = this.rayTrace(world, player, false); if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) { @@ -93,8 +91,9 @@ public class ItemRitualReader extends Item implements IVariantProvider } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); if (!world.isRemote) { EnumRitualReaderState state = this.getState(stack); @@ -123,11 +122,11 @@ public class ItemRitualReader extends Item implements IVariantProvider break; case SET_WILL_TYPES: List typeList = new ArrayList(); - ItemStack[] inv = player.inventory.mainInventory; + NonNullList inv = player.inventory.mainInventory; for (int i = 0; i < 9; i++) { - ItemStack testStack = inv[i]; - if (testStack == null) + ItemStack testStack = inv.get(i); + if (testStack.isEmpty()) { continue; } @@ -177,7 +176,7 @@ public class ItemRitualReader extends Item implements IVariantProvider } } - return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); + return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } public BlockPos getBlockPos(ItemStack stack) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java index 29ebda58..effde62c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSacrificialDagger.java @@ -63,7 +63,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); @@ -81,7 +81,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider @Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { - if (entityLiving instanceof EntityPlayer && !entityLiving.worldObj.isRemote) + if (entityLiving instanceof EntityPlayer && !entityLiving.getEntityWorld().isRemote) PlayerSacrificeHelper.sacrificePlayerHealth((EntityPlayer) entityLiving); } @@ -98,10 +98,11 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (PlayerHelper.isFakePlayer(player)) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (this.canUseForSacrifice(stack)) { @@ -124,7 +125,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider { SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, ConfigHandler.sacrificialDaggerDamage, lpAdded); if (MinecraftForge.EVENT_BUS.post(evt)) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); if (evt.shouldDrainHealth) { @@ -140,7 +141,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider } if (!evt.shouldFillAltar) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); lpAdded = evt.lpAdded; } @@ -154,12 +155,12 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0); if (!world.isRemote && PlayerHelper.isFakePlayer(player)) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); // TODO - Check if SoulFray is active PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded, false); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java b/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java index 4fb5aa1d..d654b58f 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSanguineBook.java @@ -44,10 +44,10 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (world.isRemote) - return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); + return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); IBlockState hitState = world.getBlockState(pos); if (player.isSneaking()) @@ -60,19 +60,20 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa if (!docs.isEmpty()) { ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()])); - return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); + return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } } } - return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ); + return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); stack = NBTHelper.checkNBT(stack); @@ -87,10 +88,10 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa currentDisplayedTier = EnumAltarTier.values()[stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER)]; ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.BloodMagic.altarMaker.setTier", NumeralHelper.toRoman(stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1))); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } public boolean trySetDisplayedTier(World world, BlockPos pos) diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java index f8552ec5..de787725 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemSlate.java @@ -8,6 +8,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -32,7 +33,7 @@ public class ItemSlate extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java index e717c234..2323bb42 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemTelepositionFocus.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -47,14 +48,14 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if (player.isSneaking()) { @@ -62,11 +63,11 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { - setBlockPos(stack, world, mop.getBlockPos()); + setBlockPos(player.getHeldItem(hand), world, mop.getBlockPos()); } } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java index 63c83d4c..6a983175 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTome.java @@ -11,6 +11,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -41,41 +42,42 @@ public class ItemUpgradeTome extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) { - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack); if (upgrade == null) { - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); - if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour) + if (chestStack.getItem() instanceof ItemLivingArmour) { LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack); if (armour == null) { - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } if (armour.upgradeArmour(player, upgrade)) { ItemLivingArmour.setLivingArmour(chestStack, armour); // ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false); - stack.stackSize--; + stack.shrink(1); } } - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) { diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java index df338564..ba43e781 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemUpgradeTrainer.java @@ -12,6 +12,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -35,7 +36,7 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { list.add(new ItemStack(this)); for (Entry entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) diff --git a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java index acb4e8ce..086cfcfe 100644 --- a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java +++ b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemCuttingFluid.java @@ -9,6 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -67,7 +68,7 @@ public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomA @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.size(); i++) list.add(new ItemStack(id, 1, i)); diff --git a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java index 1d6c05d2..7e71c112 100644 --- a/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/item/alchemy/ItemLivingArmourPointsUpgrade.java @@ -16,6 +16,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -68,7 +69,7 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi if (player == null || !player.capabilities.isCreativeMode) { - --stack.stackSize; + stack.shrink(1); } if (!worldIn.isRemote) @@ -109,10 +110,10 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi } @Override - public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { playerIn.setActiveHand(hand); - return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); + return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand)); } private void buildItemList() @@ -128,7 +129,7 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.size(); i++) list.add(new ItemStack(id, 1, i)); @@ -151,7 +152,7 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi public static ItemStack getStack(String key, int stackSize) { ItemStack stack = getStack(key); - stack.stackSize = stackSize; + stack.setCount(stackSize); return stack; } diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java index f5dc8800..d45d9f65 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java @@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; @@ -173,12 +174,12 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes int maxAbsorption = 100000; - if (source.equals(DamageSource.drown)) + if (source.equals(DamageSource.DROWN)) { return new ArmorProperties(-1, 0, 0); } - if (source.equals(DamageSource.outOfWorld)) + if (source.equals(DamageSource.OUT_OF_WORLD)) { return new ArmorProperties(-1, 0, 0); } @@ -191,7 +192,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS); ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if (helmet == null || leggings == null || boots == null) + if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) { damageAmount *= (armourReduction); @@ -371,18 +372,18 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes Multimap multimap = HashMultimap.create(); if (slot == EntityEquipmentSlot.CHEST) { - multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0)); - multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 8145), "Armor modifier", this.getKnockbackResistance(stack), 0)); - multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 94021), "Armor modifier", this.getSpeedBoost(stack), 2)); - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 96721), "Armor modifier", this.getDamageBoost(stack), 2)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 73245), "Armor modifier", this.getAttackSpeedBoost(stack), 2)); + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0)); + multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(new UUID(0, 8145), "Armor modifier", this.getKnockbackResistance(stack), 0)); + multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 94021), "Armor modifier", this.getSpeedBoost(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(new UUID(0, 96721), "Armor modifier", this.getDamageBoost(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(new UUID(0, 73245), "Armor modifier", this.getAttackSpeedBoost(stack), 2)); } return multimap; } public static void revertAllArmour(EntityPlayer player) { - ItemStack[] armourInventory = player.inventory.armorInventory; + NonNullList armourInventory = player.inventory.armorInventory; for (ItemStack stack : armourInventory) { if (stack != null && stack.getItem() instanceof ItemSentientArmour) @@ -423,9 +424,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } NBTTagCompound tag = omegaTag.getCompoundTag("armour"); - ItemStack armourStack = ItemStack.loadItemStackFromNBT(tag); - - return armourStack; + return new ItemStack(tag); } public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) diff --git a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java index d9baff09..48b35ea4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/ItemBlockBloodTank.java @@ -12,6 +12,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; @@ -20,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class ItemBlockBloodTank extends ItemBlock implements IFluidContainerItem +public class ItemBlockBloodTank extends ItemBlock { public ItemBlockBloodTank(Block block) { @@ -68,98 +69,17 @@ public class ItemBlockBloodTank extends ItemBlock implements IFluidContainerItem @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++) list.add(new ItemStack(id, 1, i)); } - @Override - public FluidStack getFluid(ItemStack stack) - { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.TANK) && !stack.getTagCompound().getCompoundTag(Constants.NBT.TANK).getString("FluidName").equals("")) - { - NBTTagCompound tag = stack.getTagCompound().getCompoundTag(Constants.NBT.TANK); - return FluidStack.loadFluidStackFromNBT(tag); - } - - return null; - } - - @Override public int getCapacity(ItemStack container) { return container != null && Block.getBlockFromItem(container.getItem()) instanceof BlockBloodTank ? TileBloodTank.CAPACITIES[container.getMetadata()] * Fluid.BUCKET_VOLUME : 0; } - @Override - public int fill(ItemStack stack, FluidStack resource, boolean doFill) - { - if (resource == null || stack.stackSize != 1) - return 0; - - int fillAmount = 0, capacity = getCapacity(stack); - NBTTagCompound tag = stack.getTagCompound(), fluidTag = null; - FluidStack fluid = null; - - if (tag == null || !tag.hasKey(Constants.NBT.TANK) || (fluidTag = tag.getCompoundTag(Constants.NBT.TANK)) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null) - fillAmount = Math.min(capacity, resource.amount); - - if (fluid == null) - { - if (doFill) - { - fluid = resource.copy(); - fluid.amount = 0; - } - } - else if (!fluid.isFluidEqual(resource)) - return 0; - else - fillAmount = Math.min(capacity - fluid.amount, resource.amount); - - fillAmount = Math.max(fillAmount, 0); - - if (doFill) - { - if (tag == null) - stack.setTagCompound(new NBTTagCompound()); - - tag = stack.getTagCompound(); - fluid.amount += fillAmount; - tag.setTag(Constants.NBT.TANK, fluid.writeToNBT(fluidTag == null ? new NBTTagCompound() : fluidTag)); - } - - return fillAmount; - } - - @Override - public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain) - { - NBTTagCompound tag = stack.getTagCompound(), fluidTag = null; - FluidStack fluid; - - if (tag == null || !tag.hasKey(Constants.NBT.TANK) || (fluidTag = tag.getCompoundTag(Constants.NBT.TANK)) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null) - { - if (fluidTag != null) - tag.removeTag(Constants.NBT.TANK); - return null; - } - - int drainAmount = Math.min(maxDrain, fluid.amount); - - if (doDrain) - { - tag.removeTag(Constants.NBT.TANK); - fluid.amount -= drainAmount; - if (fluid.amount > 0) - fill(stack, fluid, true); - } - - fluid.amount = drainAmount; - return fluid; - } - @Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { diff --git a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java index 9b9f825e..9efd5ff4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockEnum.java @@ -27,7 +27,7 @@ public class ItemBlockEnum & IStringSerializable> extends Item @Override public String getUnlocalizedName(ItemStack stack) { - return getBlock().getUnlocalizedName() + getBlock().getTypes()[MathHelper.clamp_int(stack.getItemDamage(), 0, 15)].getName(); + return getBlock().getUnlocalizedName() + getBlock().getTypes()[MathHelper.clamp(stack.getItemDamage(), 0, 15)].getName(); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java index 3fdea986..37e51279 100644 --- a/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java +++ b/src/main/java/WayofTime/bloodmagic/item/block/base/ItemBlockString.java @@ -22,7 +22,7 @@ public class ItemBlockString extends ItemBlock { @Override public String getUnlocalizedName(ItemStack stack) { - return getBlock().getUnlocalizedName() + "." + getBlock().getTypes()[MathHelper.clamp_int(stack.getItemDamage(), 0, 15)]; + return getBlock().getUnlocalizedName() + "." + getBlock().getTypes()[MathHelper.clamp(stack.getItemDamage(), 0, 15)]; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java index 0ea4f2e8..57bceebb 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSacrifice.java @@ -38,8 +38,9 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); @@ -47,7 +48,7 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I if (rayTrace == null) { - return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND); + return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); } else { if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) @@ -55,7 +56,7 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I TileEntity tile = world.getTileEntity(rayTrace.getBlockPos()); if (!(tile instanceof IBloodAltar)) - return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND); + return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, rayTrace.getBlockPos()); } diff --git a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java index d5c74e74..c71772d4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java +++ b/src/main/java/WayofTime/bloodmagic/item/gear/ItemPackSelfSacrifice.java @@ -54,8 +54,9 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) return ActionResult.newResult(EnumActionResult.FAIL, stack); @@ -63,7 +64,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato if (position == null) { - return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND); + return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); } else { if (position.typeOfHit == RayTraceResult.Type.BLOCK) @@ -71,7 +72,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato TileEntity tile = world.getTileEntity(position.getBlockPos()); if (!(tile instanceof IBloodAltar)) - return super.onItemRightClick(stack, world, player, EnumHand.MAIN_HAND); + return super.onItemRightClick(world, player, EnumHand.MAIN_HAND); LPContainer.tryAndFillAltar((IBloodAltar) tile, stack, world, position.getBlockPos()); } diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java b/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java index c95f2497..16d205d6 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/ContainerHolding.java @@ -59,7 +59,7 @@ public class ContainerHolding extends Container { super.onContainerClosed(entityPlayer); - if (!entityPlayer.worldObj.isRemote) + if (!entityPlayer.getEntityWorld().isRemote) { saveInventory(entityPlayer); } @@ -70,7 +70,7 @@ public class ContainerHolding extends Container { super.detectAndSendChanges(); - if (!player.worldObj.isRemote) + if (!player.getEntityWorld().isRemote) { saveInventory(player); } @@ -79,8 +79,8 @@ public class ContainerHolding extends Container @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { - ItemStack stack = null; - Slot slotObject = (Slot) inventorySlots.get(slotIndex); + ItemStack stack = ItemStack.EMPTY; + Slot slotObject = inventorySlots.get(slotIndex); int slots = inventorySlots.size(); if (slotObject != null && slotObject.getHasStack()) @@ -94,11 +94,11 @@ public class ContainerHolding extends Container { if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, slots, false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(stackInSlot, 0, ItemSigilHolding.inventorySize, false)) { - return null; + return ItemStack.EMPTY; } } else if (stack.getItem() instanceof ItemSigilHolding) { @@ -106,28 +106,28 @@ public class ContainerHolding extends Container { if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false)) { - return null; + return ItemStack.EMPTY; } } else if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false)) { - return null; + return ItemStack.EMPTY; } } - if (stackInSlot.stackSize == 0) + if (stackInSlot.isEmpty()) { - slotObject.putStack(null); + slotObject.putStack(ItemStack.EMPTY); } else { slotObject.onSlotChanged(); } - if (stackInSlot.stackSize == stack.stackSize) + if (stackInSlot.getCount() == stack.getCount()) { - return null; + return ItemStack.EMPTY; } - slotObject.onPickupFromSlot(player, stackInSlot); + slotObject.onTake(player, stackInSlot); } return stack; diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java b/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java index e14c2b2f..60a8447a 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/InventoryHolding.java @@ -40,7 +40,7 @@ public class InventoryHolding extends ItemInventory { ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i); - if (itemStack != null && Utils.hasUUID(itemStack)) + if (!itemStack.isEmpty() && Utils.hasUUID(itemStack)) { if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits()) { diff --git a/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java b/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java index dcea591a..d27d816e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java +++ b/src/main/java/WayofTime/bloodmagic/item/inventory/ItemInventory.java @@ -62,7 +62,7 @@ public class ItemInventory implements IInventory if (j >= 0 && j < inventory.length) { - inventory[j] = ItemStack.loadItemStackFromNBT(data); + inventory[j] = new ItemStack(data); } } } @@ -123,22 +123,22 @@ public class ItemInventory implements IInventory @Override public ItemStack decrStackSize(int index, int count) { - if (inventory[index] != null) + if (!inventory[index].isEmpty()) { // if (!worldObj.isRemote) // worldObj.markBlockForUpdate(this.pos); - if (inventory[index].stackSize <= count) + if (inventory[index].getCount() <= count) { ItemStack itemStack = inventory[index]; - inventory[index] = null; + inventory[index] = ItemStack.EMPTY; markDirty(); return itemStack; } ItemStack itemStack = inventory[index].splitStack(count); - if (inventory[index].stackSize == 0) - inventory[index] = null; + if (inventory[index].isEmpty()) + inventory[index] = ItemStack.EMPTY; markDirty(); return itemStack; @@ -153,7 +153,7 @@ public class ItemInventory implements IInventory if (inventory[slot] != null) { ItemStack itemStack = inventory[slot]; - setInventorySlotContents(slot, null); + setInventorySlotContents(slot, ItemStack.EMPTY); return itemStack; } return null; @@ -163,8 +163,8 @@ public class ItemInventory implements IInventory public void setInventorySlotContents(int slot, ItemStack stack) { inventory[slot] = stack; - if (stack != null && stack.stackSize > getInventoryStackLimit()) - stack.stackSize = getInventoryStackLimit(); + if (stack.getCount() > getInventoryStackLimit()) + stack.setCount(getInventoryStackLimit()); markDirty(); // if (!worldObj.isRemote) // worldObj.markBlockForUpdate(this.pos); @@ -177,7 +177,7 @@ public class ItemInventory implements IInventory } @Override - public boolean isUseableByPlayer(EntityPlayer player) + public boolean isUsableByPlayer(EntityPlayer player) { return true; } @@ -251,6 +251,11 @@ public class ItemInventory implements IInventory } } + @Override + public boolean isEmpty() { + return false; + } + public boolean canInventoryBeManipulated() { return masterStack != null; diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java index d3e96eac..98f0d385 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemNodeRouter.java @@ -53,8 +53,9 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); if (world.isRemote) { return EnumActionResult.PASS; diff --git a/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java b/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java index 3ff83caa..2888a9b7 100644 --- a/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java +++ b/src/main/java/WayofTime/bloodmagic/item/routing/ItemRouterFilter.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; @@ -49,7 +50,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); @@ -110,7 +111,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari @Override public IItemFilter getOutputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) { - IItemFilter testFilter = new TestItemFilter(); + IItemFilter testFilter; switch (filterStack.getMetadata()) { @@ -142,9 +143,9 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari } ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack); - if (ghostStack.stackSize == 0) + if (ghostStack.isEmpty()) { - ghostStack.stackSize = Integer.MAX_VALUE; + ghostStack.setCount(Integer.MAX_VALUE); } filteredList.add(ghostStack); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java index 5e615643..515f6440 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemMonsterSoul.java @@ -12,6 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -43,7 +44,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i)); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java index 34830ea0..6b13d6b3 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -33,10 +34,10 @@ public class ItemSentientArmourGem extends Item } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { boolean hasSentientArmour = false; - ItemStack[] armourInventory = player.inventory.armorInventory; + NonNullList armourInventory = player.inventory.armorInventory; for (ItemStack armourStack : armourInventory) { if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) @@ -57,14 +58,14 @@ public class ItemSentientArmourGem extends Item ItemSentientArmour.convertPlayerArmour(type, will, player); } - return new ActionResult(EnumActionResult.PASS, stack); + return new ActionResult(EnumActionResult.PASS, player.getHeldItem(hand)); } @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { boolean hasSentientArmour = false; - ItemStack[] armourInventory = player.inventory.armorInventory; + NonNullList armourInventory = player.inventory.armorInventory; for (ItemStack armourStack : armourInventory) { if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java index 255ac5d9..eca6badd 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientAxe.java @@ -100,7 +100,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { - return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); + return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) @@ -224,7 +224,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; - this.recalculatePowers(stack, attackerPlayer.worldObj, attackerPlayer); + this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer); int willBracket = this.getLevel(stack, will); @@ -232,7 +232,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack != null && offStack.getItem() instanceof ISentientSwordEffectProvider) + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); if (provider.providesEffectForWill(type)) @@ -273,11 +273,11 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - recalculatePowers(stack, world, player); + recalculatePowers(player.getHeldItem(hand), world, player); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @@ -314,7 +314,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - recalculatePowers(stack, player.worldObj, player); + recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); if (drain > 0) @@ -365,7 +365,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP { List soulList = new ArrayList(); - if (killedEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -378,9 +378,9 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP for (int i = 0; i <= looting; i++) { - if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { - ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); + ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } } @@ -395,10 +395,10 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP Multimap multimap = HashMultimap.create(); if (slot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); } return multimap; @@ -543,7 +543,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP @Override public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); @@ -559,7 +559,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP EntitySentientSpecter specterEntity = new EntitySentientSpecter(world); specterEntity.setPosition(player.posX, player.posY, player.posZ); - world.spawnEntityInWorld(specterEntity); + world.spawnEntity(specterEntity); specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy()); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index 29505a45..366c29ba 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -60,7 +60,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } else { ItemStack itemstack = entityIn.getActiveItemStack(); - return itemstack != null && itemstack.getItem() == ModItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; + return !itemstack.isEmpty() && itemstack.getItem() == ModItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; } } }); @@ -85,7 +85,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { - return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); + return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) @@ -275,10 +275,11 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); this.recalculatePowers(stack, world, player); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) @@ -294,7 +295,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien double d0 = target.posX - user.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityArrow.posY; double d2 = target.posZ - user.posZ; - double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); + double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityArrow.setThrowableHeading(d0, d1 + d3 * 0.05, d2, newArrowVelocity, 0); if (newArrowVelocity == 0) @@ -405,16 +406,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } - world.spawnEntityInWorld(entityArrow); + world.spawnEntity(entityArrow); } world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + arrowVelocity * 0.5F); if (!flag1) { - --itemstack.stackSize; + itemstack.shrink(1); - if (itemstack.stackSize == 0) + if (itemstack.isEmpty()) { player.inventory.deleteStack(itemstack); } @@ -453,7 +454,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien @Override public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); @@ -469,7 +470,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien EntitySentientSpecter specterEntity = new EntitySentientSpecter(world); specterEntity.setPosition(player.posX, player.posY, player.posZ); - world.spawnEntityInWorld(specterEntity); + world.spawnEntity(specterEntity); specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy()); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java index 9ccef5ad..96bd90db 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientPickaxe.java @@ -224,7 +224,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; - this.recalculatePowers(stack, attackerPlayer.worldObj, attackerPlayer); + this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer); int willBracket = this.getLevel(stack, will); @@ -232,7 +232,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack != null && offStack.getItem() instanceof ISentientSwordEffectProvider) + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); if (provider.providesEffectForWill(type)) @@ -273,11 +273,10 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - recalculatePowers(stack, world, player); - - return super.onItemRightClick(stack, world, player, hand); + recalculatePowers(player.getHeldItem(hand), world, player); + return super.onItemRightClick(world, player, hand); } @Override @@ -314,7 +313,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - recalculatePowers(stack, player.worldObj, player); + recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); if (drain > 0) @@ -365,7 +364,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon { List soulList = new ArrayList(); - if (killedEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -378,9 +377,9 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon for (int i = 0; i <= looting; i++) { - if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { - ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); + ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } } @@ -395,10 +394,10 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon Multimap multimap = HashMultimap.create(); if (slot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); } return multimap; @@ -543,7 +542,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon @Override public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); @@ -559,7 +558,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon EntitySentientSpecter specterEntity = new EntitySentientSpecter(world); specterEntity.setPosition(player.posX, player.posY, player.posZ); - world.spawnEntityInWorld(specterEntity); + world.spawnEntity(specterEntity); specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy()); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java index 664afb3e..ed3a1c3e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientShovel.java @@ -100,7 +100,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { - return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); + return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) @@ -224,7 +224,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; - this.recalculatePowers(stack, attackerPlayer.worldObj, attackerPlayer); + this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer); int willBracket = this.getLevel(stack, will); @@ -232,7 +232,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack != null && offStack.getItem() instanceof ISentientSwordEffectProvider) + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); if (provider.providesEffectForWill(type)) @@ -273,11 +273,11 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - recalculatePowers(stack, world, player); + recalculatePowers(player.getHeldItem(hand), world, player); - return super.onItemRightClick(stack, world, player, hand); + return super.onItemRightClick(world, player, hand); } @Override @@ -314,7 +314,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - recalculatePowers(stack, player.worldObj, player); + recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); if (drain > 0) @@ -365,7 +365,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I { List soulList = new ArrayList(); - if (killedEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -378,9 +378,9 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I for (int i = 0; i <= looting; i++) { - if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { - ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); + ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } } @@ -395,10 +395,10 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I Multimap multimap = HashMultimap.create(); if (slot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); } return multimap; @@ -543,7 +543,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I @Override public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); @@ -559,7 +559,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I EntitySentientSpecter specterEntity = new EntitySentientSpecter(world); specterEntity.setPosition(player.posX, player.posY, player.posZ); - world.spawnEntityInWorld(specterEntity); + world.spawnEntity(specterEntity); specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy()); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index bbc5cc5d..cb39ba52 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -79,7 +79,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM @Override public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { - return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair); + return ModItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) @@ -196,7 +196,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM if (attacker instanceof EntityPlayer) { EntityPlayer attackerPlayer = (EntityPlayer) attacker; - this.recalculatePowers(stack, attackerPlayer.worldObj, attackerPlayer); + this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer); EnumDemonWillType type = this.getCurrentType(stack); double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer); int willBracket = this.getLevel(stack, will); @@ -204,7 +204,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM applyEffectToEntity(type, willBracket, target, attackerPlayer); ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); - if (offStack != null && offStack.getItem() instanceof ISentientSwordEffectProvider) + if (offStack.getItem() instanceof ISentientSwordEffectProvider) { ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem(); if (provider.providesEffectForWill(type)) @@ -245,11 +245,10 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - recalculatePowers(stack, world, player); - - return super.onItemRightClick(stack, world, player, hand); + recalculatePowers(player.getHeldItem(hand), world, player); + return super.onItemRightClick(world, player, hand); } @Override @@ -286,7 +285,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { - recalculatePowers(stack, player.worldObj, player); + recalculatePowers(stack, player.getEntityWorld(), player); double drain = this.getDrainOfActivatedSword(stack); if (drain > 0) @@ -337,7 +336,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM { List soulList = new ArrayList(); - if (killedEntity.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) + if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) { return soulList; } @@ -350,9 +349,9 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM for (int i = 0; i <= looting; i++) { - if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) + if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) { - ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); + ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } } @@ -367,10 +366,10 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM Multimap multimap = HashMultimap.create(); if (slot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); - multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0)); + multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), 2)); } return multimap; @@ -498,7 +497,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM @Override public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { - World world = player.worldObj; + World world = player.getEntityWorld(); if (!world.isRemote) { this.recalculatePowers(droppedStack, world, player); @@ -514,7 +513,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM EntitySentientSpecter specterEntity = new EntitySentientSpecter(world); specterEntity.setPosition(player.posX, player.posY, player.posZ); - world.spawnEntityInWorld(specterEntity); + world.spawnEntity(specterEntity); specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, droppedStack.copy()); diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java index 4e6adfa5..dd31e472 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulGem.java @@ -12,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -52,8 +49,9 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); EnumDemonWillType type = this.getCurrentType(stack); double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10); @@ -95,7 +93,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) { diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java index b1107f31..e1dfb842 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSoulSnare.java @@ -10,10 +10,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -40,23 +37,24 @@ public class ItemSoulSnare extends Item implements IVariantProvider } @Override - public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { + ItemStack stack = playerIn.getHeldItem(hand); if (!playerIn.capabilities.isCreativeMode) { - --itemStackIn.stackSize; + stack.shrink(1); } - worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn); snare.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); - worldIn.spawnEntityInWorld(snare); + worldIn.spawnEntity(snare); } - return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); + return new ActionResult(EnumActionResult.SUCCESS, stack); } @Override @@ -67,7 +65,7 @@ public class ItemSoulSnare extends Item implements IVariantProvider @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item id, CreativeTabs creativeTab, List list) + public void getSubItems(Item id, CreativeTabs creativeTab, NonNullList list) { for (int i = 0; i < names.length; i++) list.add(new ItemStack(id, 1, i));