All items compiling

This commit is contained in:
Vincent Lee committed 2017-01-05 02:16:04 -06:00
1 parent d1ba09bf89
commit 641dc80490
77 files changed
+409 -341

No files matched your search

@@ -62,7 +62,7 @@ public class WrappedDeepStorage extends WrappedInventoryBase {
// for the case of barrel without contents set
return stacks;
}
int storedCount = prototype.stackSize;
int storedCount = prototype.getCount();
// WARNING: this code is very similar in all implementations of
// IWrappedInventory - keep it synch
@@ -73,7 +73,7 @@ public class WrappedDeepStorage extends WrappedInventoryBase {
if(rem > 0) {
ItemStack copy = prototype.copy();
copy.stackSize = rem;
copy.setCount(rem);
if(doit) {
stacks.addAll(breakDownBigStack(copy));
} else {
@@ -101,7 +101,7 @@ public class WrappedDeepStorage extends WrappedInventoryBase {
}
private void decreaseStoredCount(IDeepStorageUnit inventory, int rem) {
inventory.setStoredItemCount(inventory.getStoredItemType().stackSize - rem);
inventory.setStoredItemCount(inventory.getStoredItemType().getCount() - rem);
}
/**
@@ -50,7 +50,7 @@ public class WrappedIInventory extends WrappedInventoryBase{
// WARNING: this code is very similar in all implementations of
// IWrappedInventory - keep it synch
if(isMatchingItemStack(request.matcher, request.checkNBT, stackAt)) {
int rem = Math.min(stackAt.stackSize, request.count == -1 ? stackAt.stackSize : request.count);
int rem = Math.min(stackAt.getCount(), request.count == -1 ? stackAt.getCount() : request.count);
if(rem > 0) {
stacks.add(inv.handler.extractItem(i, rem, !doit));
@@ -58,7 +58,7 @@ public class WrappedIInventory extends WrappedInventoryBase{
spark.onItemExtracted(stackAt);
}
request.foundItems += stackAt.stackSize;
request.foundItems += stackAt.getCount();
request.extractedItems += rem;
if(request.count != -1)
@@ -34,17 +34,17 @@ public abstract class WrappedInventoryBase implements IWrappedInventory {
protected Collection<? extends ItemStack> breakDownBigStack(ItemStack stack) {
List<ItemStack> stacks = new ArrayList<ItemStack>();
int additionalStacks = stack.stackSize / stack.getMaxStackSize();
int lastStackSize = stack.stackSize % stack.getMaxStackSize();
int additionalStacks = stack.getCount() / stack.getMaxStackSize();
int lastStackSize = stack.getCount() % stack.getMaxStackSize();
if(additionalStacks > 0) {
ItemStack fullStack = stack.copy();
fullStack.stackSize = stack.getMaxStackSize();
fullStack.setCount(stack.getMaxStackSize());
for (int i = 0; i < additionalStacks; i++) {
stacks.add(fullStack.copy());
}
}
ItemStack lastStack = stack.copy();
lastStack.stackSize = lastStackSize;
lastStack.setCount(lastStackSize);
stacks.add(lastStack);
return stacks;
@@ -72,7 +72,7 @@ public class WrappedStorageDrawers extends WrappedInventoryBase {
if(rem > 0) {
ItemStack copy = prototype.copy();
copy.stackSize = rem;
copy.setCount(rem);
if(doit) {
stacks.addAll(breakDownBigStack(copy));
} else {
@@ -53,7 +53,8 @@ public class ItemAstrolabe extends ItemMod {
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(hand);
IBlockState state = worldIn.getBlockState(pos);
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
@@ -78,18 +79,19 @@ public class ItemAstrolabe extends ItemMod {
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack stack = playerIn.getHeldItem(hand);
if(playerIn.isSneaking()) {
int size = getSize(itemStackIn);
int size = getSize(stack);
int newSize = size == 11 ? 3 : size + 2;
setSize(itemStackIn, newSize);
ItemsRemainingRenderHandler.set(itemStackIn, newSize + "x" + newSize);
setSize(stack, newSize);
ItemsRemainingRenderHandler.set(stack, newSize + "x" + newSize);
worldIn.playSound(playerIn, playerIn.getPosition(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F);
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return new ActionResult(EnumActionResult.PASS, itemStackIn);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
public boolean placeAllBlocks(ItemStack stack, EntityPlayer player) {
@@ -123,18 +125,18 @@ public class ItemAstrolabe extends ItemMod {
if(player.capabilities.isCreativeMode)
return;
List<ItemStack> stacksToCheck = new ArrayList();
List<ItemStack> stacksToCheck = new ArrayList<>();
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if(stackInSlot != null && stackInSlot.getItem() == blockToPlace.getItem() && stackInSlot.getItemDamage() == blockToPlace.getItemDamage()) {
stackInSlot.stackSize--;
if(stackInSlot.stackSize == 0)
player.inventory.setInventorySlotContents(i, null);
if(!stackInSlot.isEmpty() && stackInSlot.getItem() == blockToPlace.getItem() && stackInSlot.getItemDamage() == blockToPlace.getItemDamage()) {
stackInSlot.shrink(1);
if(stackInSlot.isEmpty())
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
return;
}
if (stackInSlot != null && stackInSlot.getItem() instanceof IBlockProvider)
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider)
stacksToCheck.add(stackInSlot);
}
@@ -158,15 +160,15 @@ public class ItemAstrolabe extends ItemMod {
int required = blocks.length;
int current = 0;
List<ItemStack> stacksToCheck = new ArrayList();
List<ItemStack> stacksToCheck = new ArrayList<>();
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if (stackInSlot != null && stackInSlot.getItem() == reqStack.getItem() && stackInSlot.getItemDamage() == reqStack.getItemDamage()) {
current += stackInSlot.stackSize;
if (!stackInSlot.isEmpty() && stackInSlot.getItem() == reqStack.getItem() && stackInSlot.getItemDamage() == reqStack.getItemDamage()) {
current += stackInSlot.getCount();
if (current >= required)
return true;
}
if(stackInSlot != null && stackInSlot.getItem() instanceof IBlockProvider)
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IBlockProvider)
stacksToCheck.add(stackInSlot);
}
@@ -186,7 +188,7 @@ public class ItemAstrolabe extends ItemMod {
}
public static BlockPos[] getBlocksToPlace(ItemStack stack, EntityPlayer player) {
List<BlockPos> coords = new ArrayList();
List<BlockPos> coords = new ArrayList<>();
RayTraceResult pos = ToolCommons.raytraceFromEntity(player.world, player, true, 5);
if(pos != null) {
BlockPos bpos = pos.getBlockPos();
@@ -105,9 +105,9 @@ public class ItemBaubleBox extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, hand == EnumHand.OFF_HAND ? 1 : 0, 0, 0);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
}
@@ -63,7 +63,8 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(getBlock(stack) != Blocks.AIR && player.isSneaking()) {
int dmg = stack.getItemDamage();
stack.setItemDamage(~dmg & 1);
@@ -76,8 +77,9 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState state = world.getBlockState(pos);
ItemStack stack = player.getHeldItem(hand);
if (Item.getItemFromBlock(state.getBlock()) != null
&& setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state))) {
@@ -95,17 +97,22 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
ItemStack toAdd = new ItemStack(bBlock, 1, bmeta);
int maxSize = toAdd.getMaxStackSize();
toAdd.stackSize = remove(stack, maxSize);
toAdd.setCount(remove(stack, maxSize));
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
if(remainder != null)
add(stack, remainder.stackSize);
if(!remainder.isEmpty())
add(stack, remainder.getCount());
}
return EnumActionResult.SUCCESS;
} else {
if(player.capabilities.isCreativeMode || getBlockCount(stack) > 0) {
ItemStack toUse = new ItemStack(bBlock, 1, bmeta);
if (Item.getItemFromBlock(bBlock).onItemUse(toUse, player, world, pos, hand, side, hitX, hitY, hitZ) == EnumActionResult.SUCCESS) {
ItemStack saveHeldItem = player.getHeldItem(hand);
player.setHeldItem(hand, toUse);
EnumActionResult result = Item.getItemFromBlock(bBlock).onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
player.setHeldItem(hand, saveHeldItem);
if (result == EnumActionResult.SUCCESS) {
remove(stack, 1);
ItemsRemainingRenderHandler.set(toUse, getBlockCount(stack));
return EnumActionResult.SUCCESS;
@@ -125,16 +132,16 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
int meta = getBlockMeta(itemstack);
int highest = -1;
int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.length];
int[] counts = new int[player.inventory.getSizeInventory() - player.inventory.armorInventory.size()];
for(int i = 0; i < counts.length; i++) {
ItemStack stack = player.inventory.getStackInSlot(i);
if(stack == null) {
if(stack.isEmpty()) {
continue;
}
if(Item.getItemFromBlock(block) == stack.getItem() && stack.getItemDamage() == meta) {
counts[i] = stack.stackSize;
counts[i] = stack.getCount();
if(highest == -1)
highest = i;
else highest = counts[i] > counts[highest] && highest > 8 ? i : highest;
@@ -71,7 +71,7 @@ public class ItemBlackLotus extends ItemMod implements IManaDissolvable {
if(!item.world.isRemote) {
pool.recieveMana(t2 ? MANA_PER_T2 : MANA_PER);
stack.stackSize--;
stack.shrink(1);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(item.world, tile.getPos());
}
@@ -180,7 +180,7 @@ public class ItemBottledMana extends ItemMod {
}
case 15 : { // Drop own Head
if(!living.world.isRemote && living instanceof EntityPlayer) {
living.attackEntityFrom(DamageSource.magic, living.getHealth() - 1);
living.attackEntityFrom(DamageSource.MAGIC, living.getHealth() - 1);
ItemStack skull = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(skull, "SkullOwner", living.getName());
living.entityDropItem(skull, 0);
@@ -218,9 +218,9 @@ public class ItemBottledMana extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -101,13 +101,14 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
ItemStack stack = player.getHeldItem(hand);
if(getSound(stack) != null) {
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.NOTEBLOCK) {
world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState());
((TileCacophonium) world.getTileEntity(pos)).stack = stack.copy();
stack.stackSize--;
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
}
@@ -137,7 +138,8 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(getSound(stack) != null)
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
@@ -49,11 +49,12 @@ public class ItemCorporeaSpark extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xv, float yv, float zv) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP) || tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
&& !CorporeaHelper.doesBlockHaveSpark(world, pos)) {
stack.stackSize--;
ItemStack stack = player.getHeldItem(hand);
stack.shrink(1);
if(!world.isRemote) {
EntityCorporeaSpark spark = new EntityCorporeaSpark(world);
if(stack.getItemDamage() == 1)
@@ -41,11 +41,11 @@ public class ItemCraftPattern extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer p, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(EntityPlayer p, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileCraftCrate) {
TileCraftCrate crate = (TileCraftCrate) tile;
crate.pattern = stack.getItemDamage();
crate.pattern = p.getHeldItem(hand).getItemDamage();
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
return EnumActionResult.SUCCESS;
}
@@ -93,14 +93,15 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int segment = getSegmentLookedAt(stack, player);
ItemStack itemForPos = getItemForSlot(stack, segment);
if(segment == 0)
player.openGui(Botania.instance, LibGuiIDs.CRAFTING_HALO, world, hand == EnumHand.OFF_HAND ? 1 : 0, 0, 0);
else {
if(itemForPos == null)
if(itemForPos.isEmpty())
assignRecipe(stack, itemForPos, segment);
else tryCraft(player, stack, segment, true, getFakeInv(player), true);
}
@@ -109,11 +110,9 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
}
public static IItemHandler getFakeInv(EntityPlayer player) {
ItemStackHandler ret = new ItemStackHandler(player.inventory.mainInventory.length);
for(int i = 0; i < player.inventory.mainInventory.length; i++) {
ItemStack stack = player.inventory.mainInventory[i];
if(stack != null)
ret.setStackInSlot(i, player.inventory.mainInventory[i].copy());
ItemStackHandler ret = new ItemStackHandler(player.inventory.mainInventory.size());
for(int i = 0; i < player.inventory.mainInventory.size(); i++) {
ret.setStackInSlot(i, player.inventory.mainInventory.get(i).copy());
}
return ret;
@@ -160,12 +159,12 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
fakeInv.setInventorySlotContents(i, recipe[i]);
ItemStack result = CraftingManager.getInstance().findMatchingRecipe(fakeInv, player.world);
if(result == null) {
if(result.isEmpty()) {
assignRecipe(stack, recipe[9], slot);
return null;
}
if(!result.isItemEqual(recipe[9]) || result.stackSize != recipe[9].stackSize || !ItemStack.areItemStackTagsEqual(recipe[9], result)) {
if(!result.isItemEqual(recipe[9]) || result.getCount() != recipe[9].getCount() || !ItemStack.areItemStackTagsEqual(recipe[9], result)) {
assignRecipe(stack, recipe[9], slot);
return null;
}
@@ -338,7 +337,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
if(stackSlot != null) {
ItemStack writeStack = stackSlot.copy();
writeStack.stackSize = 1;
writeStack.setCount(1);
writeStack.writeToNBT(cmp1);
}
cmp.setTag(TAG_ITEM_PREFIX + i, cmp1);
@@ -377,13 +376,13 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
public static ItemStack getLastCraftingItem(NBTTagCompound cmp, int pos) {
if(cmp == null)
return null;
return ItemStack.EMPTY;
NBTTagCompound cmp1 = cmp.getCompoundTag(TAG_ITEM_PREFIX + pos);
if(cmp1 == null)
return null;
return ItemStack.EMPTY;
return ItemStack.loadItemStackFromNBT(cmp1);
return new ItemStack(cmp1);
}
public static boolean wasEquipped(ItemStack stack) {
@@ -41,7 +41,8 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) {
if(!player.world.isRemote)
player.displayGUIChest(player.getInventoryEnderChest());
@@ -36,7 +36,7 @@ public class ItemFertilizer extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
final int range = 3;
if(!world.isRemote) {
List<BlockPos> validCoords = new ArrayList<>();
@@ -56,7 +56,7 @@ public class ItemFertilizer extends ItemMod {
validCoords.remove(coords);
world.setBlockState(coords, ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, EnumDyeColor.byMetadata(world.rand.nextInt(16))), 1 | 2);
}
par1ItemStack.stackSize--;
player.getHeldItem(hand).shrink(1);
} else {
for(int i = 0; i < 15; i++) {
double x = pos.getX() - range + world.rand.nextInt(range * 2 + 1) + Math.random();
@@ -120,7 +120,7 @@ public class ItemFlowerBag extends ItemMod {
@SubscribeEvent
public void onPickupItem(EntityItemPickupEvent event) {
ItemStack entityStack = event.getItem().getEntityItem();
if(entityStack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && entityStack.stackSize > 0) {
if(entityStack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && entityStack.getCount() > 0) {
int color = entityStack.getItemDamage();
if(color > 15)
return;
@@ -130,12 +130,12 @@ public class ItemFlowerBag extends ItemMod {
continue; // prevent item deletion
ItemStack bag = event.getEntityPlayer().inventory.getStackInSlot(i);
if(bag != null && bag.getItem() == this) {
if(!bag.isEmpty() && bag.getItem() == this) {
IItemHandler bagInv = bag.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
ItemStack result = bagInv.insertItem(color, entityStack, false);
if(result == null)
if(result.isEmpty())
event.getItem().setDead();
else
event.getItem().setEntityItemStack(result);
@@ -147,7 +147,7 @@ public class ItemFlowerBag extends ItemMod {
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F,
((event.getItem().world.rand.nextFloat() - event.getItem().world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
((EntityPlayerMP) event.getEntityPlayer()).connection.sendPacket(new SPacketCollectItem(event.getItem().getEntityId(), event.getEntityPlayer().getEntityId()));
((EntityPlayerMP) event.getEntityPlayer()).connection.sendPacket(new SPacketCollectItem(event.getItem().getEntityId(), event.getEntityPlayer().getEntityId(), entityStack.getCount()));
event.getEntityPlayer().openContainer.detectAndSendChanges();
return;
@@ -159,14 +159,14 @@ public class ItemFlowerBag extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, hand == EnumHand.OFF_HAND ? 1 : 0, 0, 0);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null) {
if(!world.isRemote) {
@@ -179,7 +179,7 @@ public class ItemFlowerBag extends ItemMod {
if(tileInv == null)
return EnumActionResult.FAIL;
IItemHandlerModifiable bagInv = (IItemHandlerModifiable) stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandlerModifiable bagInv = (IItemHandlerModifiable) player.getHeldItem(hand).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
for(int i = 0; i < bagInv.getSlots(); i++) {
ItemStack flower = bagInv.getStackInSlot(i);
@@ -66,7 +66,7 @@ public class ItemGaiaHead extends ItemMod {
// Copied from vanila skull itemBlock. Relevant edits are indicated.
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing == EnumFacing.DOWN) {
return EnumActionResult.FAIL;
} else {
@@ -86,7 +86,9 @@ public class ItemGaiaHead extends ItemMod {
pos = pos.offset(facing);
}
if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
ItemStack itemstack = playerIn.getHeldItem(hand);
if (playerIn.canPlayerEdit(pos, facing, itemstack) && Blocks.SKULL.canPlaceBlockAt(worldIn, pos)) {
if (worldIn.isRemote) {
return EnumActionResult.SUCCESS;
} else {
@@ -102,7 +104,7 @@ public class ItemGaiaHead extends ItemMod {
if (tileentity instanceof TileEntitySkull) {
TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
if (stack.getMetadata() == 3) // Botania - do not retrieve skins
if (itemstack.getMetadata() == 3) // Botania - do not retrieve skins
{
/*GameProfile gameprofile = null;
@@ -129,7 +131,7 @@ public class ItemGaiaHead extends ItemMod {
Blocks.SKULL.checkWitherSpawn(worldIn, pos, tileentityskull);
}
--stack.stackSize;
itemstack.shrink(1);
return EnumActionResult.SUCCESS;
}
} else {
@@ -92,9 +92,9 @@ public class ItemGrassHorn extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -85,11 +85,12 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
IBlockState state = world.getBlockState(pos);
ItemStack stack = player.getHeldItem(hand);
if(state.getBlock() == Blocks.DIRT && state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getBlock() == Blocks.GRASS && par1ItemStack.getItemDamage() != 0) {
int meta = par1ItemStack.getItemDamage();
if(state.getBlock() == Blocks.DIRT && state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT || state.getBlock() == Blocks.GRASS && stack.getItemDamage() != 0) {
int meta = stack.getItemDamage();
BlockSwapper swapper = addBlockSwapper(world, pos, meta);
world.setBlockState(pos, swapper.stateToSet, 1 | 2);
@@ -157,7 +158,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
Botania.proxy.wispFX(pos.getX() + 0.5 + x, pos.getY() + 0.5 + y, pos.getZ() + 0.5 + z, r, g, b, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul);
}
par1ItemStack.stackSize--;
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -86,7 +86,7 @@ public class ItemKeepIvy extends ItemMod {
int count = cmp1.getInteger(TAG_DROP_COUNT);
for(int i = 0; i < count; i++) {
NBTTagCompound cmp2 = cmp1.getCompoundTag(TAG_DROP_PREFIX + i);
ItemStack stack = ItemStack.loadItemStackFromNBT(cmp2);
ItemStack stack = new ItemStack(cmp2);
if(stack != null) {
ItemStack copy = stack.copy();
ItemNBTHelper.setBoolean(copy, TAG_KEEP, false);
@@ -90,12 +90,13 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(!world.isRemote && pos.getY() < 160 && !world.provider.doesWaterVaporize()) {
world.playSound(null, pos, BotaniaSoundEvents.laputaStart, SoundCategory.BLOCKS, 1.0F + world.rand.nextFloat(), world.rand.nextFloat() * 0.7F + 1.3F);
spawnBurstFirst(world, pos, par1ItemStack);
par1ItemStack.stackSize--;
if(par1ItemStack.getItemDamage() == 19)
ItemStack stack = player.getHeldItem(hand);
spawnBurstFirst(world, pos, stack);
stack.shrink(1);
if(stack.getItemDamage() == 19)
player.addStat(ModAchievements.l20ShardUse, 1);
}
@@ -73,18 +73,19 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(player.isSneaking()) {
Block block = world.getBlockState(pos).getBlock();
if(block != null) {
if(block instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) block).getEntry(world, pos, player, par1ItemStack);
if(entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) {
ItemStack stack = player.getHeldItem(hand);
LexiconEntry entry = ((ILexiconable) block).getEntry(world, pos, player, stack);
if(entry != null && isKnowledgeUnlocked(stack, entry.getKnowledgeType())) {
Botania.proxy.setEntryToOpen(entry);
Botania.proxy.setLexiconStack(par1ItemStack);
Botania.proxy.setLexiconStack(stack);
openBook(player, par1ItemStack, world, false);
openBook(player, stack, world, false);
return EnumActionResult.SUCCESS;
}
} else if(world.isRemote) {
@@ -146,20 +147,21 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
String force = getForcedPage(par1ItemStack);
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
String force = getForcedPage(stack);
if(force != null && !force.isEmpty()) {
LexiconEntry entry = getEntryFromForce(par1ItemStack);
LexiconEntry entry = getEntryFromForce(stack);
if(entry != null)
Botania.proxy.setEntryToOpen(entry);
else player.sendMessage(new TextComponentTranslation("botaniamisc.cantOpen").setStyle(new Style().setColor(TextFormatting.RED)));
setForcedPage(par1ItemStack, "");
setForcedPage(stack, "");
}
openBook(player, par1ItemStack, world, skipSound);
openBook(player, stack, world, skipSound);
skipSound = false;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
public static void openBook(EntityPlayer player, ItemStack stack, World world, boolean skipSound) {
@@ -189,7 +191,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
if(ticks > 0 && entity instanceof EntityPlayer) {
skipSound = ticks < 5;
if(ticks == 1)
onItemRightClick(stack, world, (EntityPlayer) entity, EnumHand.MAIN_HAND);
onItemRightClick(world, (EntityPlayer) entity, EnumHand.MAIN_HAND); // todo 1.11 this won't work
setQueueTicks(stack, ticks - 1);
}
@@ -77,28 +77,29 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int effCd = COOLDOWN;
PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE);
if(effect != null)
effCd -= (effect.getAmplifier() + 1) * 8;
if(player.isSneaking() && hasClip(par1ItemStack)) {
rotatePos(par1ItemStack);
if(player.isSneaking() && hasClip(stack)) {
rotatePos(stack);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
if(world.isRemote)
player.swingArm(hand);
ItemStack lens = getLens(par1ItemStack);
ItemStack lens = getLens(stack);
ItemsRemainingRenderHandler.set(lens, -2);
par1ItemStack.setItemDamage(effCd);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
} else if(par1ItemStack.getItemDamage() == 0) {
EntityManaBurst burst = getBurst(player, par1ItemStack, true);
if(burst != null && ManaItemHandler.requestManaExact(par1ItemStack, player, burst.getMana(), true)) {
stack.setItemDamage(effCd);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
} else if(stack.getItemDamage() == 0) {
EntityManaBurst burst = getBurst(player, stack, true);
if(burst != null && ManaItemHandler.requestManaExact(stack, player, burst.getMana(), true)) {
if(!world.isRemote) {
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.manaBlaster, SoundCategory.PLAYERS, 0.6F, 1);
player.addStat(ModAchievements.manaBlasterShoot, 1);
if(isSugoiKawaiiDesuNe(par1ItemStack))
if(isSugoiKawaiiDesuNe(stack))
player.addStat(ModAchievements.desuGun, 1);
world.spawnEntity(burst);
} else {
@@ -107,13 +108,13 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
player.motionY -= burst.motionY * 0.3;
player.motionZ -= burst.motionZ * 0.1;
}
par1ItemStack.setItemDamage(effCd);
stack.setItemDamage(effCd);
} else if(!world.isRemote)
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.PLAYERS, 0.6F, (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
// ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN
@@ -257,7 +258,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
public static ItemStack getLensAtPos(ItemStack stack, int pos) {
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS + pos, true);
if(cmp != null) {
return ItemStack.loadItemStackFromNBT(cmp);
return new ItemStack(cmp);
}
return null;
}
@@ -285,8 +286,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_LENS, true);
if(cmp != null) {
ItemStack lens = ItemStack.loadItemStackFromNBT(cmp);
return lens;
return new ItemStack(cmp);
}
return null;
}
@@ -78,11 +78,11 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(player.isSneaking() && !world.isRemote) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof IManaPool) {
bindPool(par1ItemStack, tile);
bindPool(player.getHeldItem(hand), tile);
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.ding, SoundCategory.PLAYERS, 1F, 1F);
return EnumActionResult.SUCCESS;
}
@@ -38,7 +38,7 @@ public class ItemObedienceStick extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
TileEntity tileAt = world.getTileEntity(pos);
if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) {
boolean pool = tileAt instanceof IManaPool;
@@ -33,20 +33,21 @@ public class ItemOpenBucket extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
RayTraceResult RayTraceResult = rayTrace(world, player, true);
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
RayTraceResult rtr = rayTrace(world, player, true);
ItemStack stack = player.getHeldItem(hand);
if(RayTraceResult == null)
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
if(rtr == null)
return ActionResult.newResult(EnumActionResult.PASS, stack);
else {
if(RayTraceResult.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK) {
BlockPos pos = RayTraceResult.getBlockPos();
if(rtr.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK) {
BlockPos pos = rtr.getBlockPos();
if(!world.isBlockModifiable(player, pos))
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
if(!player.canPlayerEdit(pos, RayTraceResult.sideHit, par1ItemStack))
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
if(!player.canPlayerEdit(pos, rtr.sideHit, stack))
return ActionResult.newResult(EnumActionResult.PASS, stack);
Material material = world.getBlockState(pos).getMaterial();
int l = world.getBlockState(pos).getBlock().getMetaFromState(world.getBlockState(pos)); // hack to get meta so we don't have to know the level prop
@@ -57,11 +58,11 @@ public class ItemOpenBucket extends ItemMod {
for(int x = 0; x < 5; x++)
world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
@@ -34,7 +34,7 @@ public class ItemOvergrowthSeed extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
IBlockState state = world.getBlockState(pos);
if(Item.getItemFromBlock(state.getBlock()) == null)
return EnumActionResult.PASS;
@@ -45,7 +45,7 @@ public class ItemOvergrowthSeed extends ItemMod {
if(name.equals("grass")) {
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockState(pos, ModBlocks.enchantedSoil.getDefaultState());
stack.stackSize--;
player.getHeldItem(hand).shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -41,7 +41,8 @@ public class ItemPinkinator extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int range = 16;
List<EntityWither> withers = world.getEntitiesWithinAABB(EntityWither.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
for(EntityWither wither : withers)
@@ -56,7 +57,7 @@ public class ItemPinkinator extends ItemMod {
player.addStat(ModAchievements.pinkinator, 1);
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D);
stack.stackSize--;
stack.shrink(1);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@@ -42,7 +42,9 @@ public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMin
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if(BlockRailBase.isRailBlock(world.getBlockState(pos))) {
if(!world.isRemote) {
EntityMinecart entityminecart = new EntityPoolMinecart(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
@@ -53,7 +55,7 @@ public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMin
world.spawnEntity(entityminecart);
}
--stack.stackSize;
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -104,23 +104,24 @@ public class ItemSextant extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
Botania.proxy.removeSextantMultiblock();
ItemStack stack = player.getHeldItem(hand);
if(!player.isSneaking()) {
RayTraceResult pos = ToolCommons.raytraceFromEntity(world, player, false, 128);
if(pos != null && pos.entityHit == null && pos.getBlockPos() != null) {
if(!world.isRemote) {
ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_X, pos.getBlockPos().getX());
ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, pos.getBlockPos().getY());
ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Z, pos.getBlockPos().getZ());
ItemNBTHelper.setInt(stack, TAG_SOURCE_X, pos.getBlockPos().getX());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, pos.getBlockPos().getY());
ItemNBTHelper.setInt(stack, TAG_SOURCE_Z, pos.getBlockPos().getZ());
}
} else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1);
} else ItemNBTHelper.setInt(stack, TAG_SOURCE_Y, -1);
player.setActiveHand(hand);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
public static double calculateRadius(ItemStack stack, EntityPlayer player) {
@@ -74,13 +74,14 @@ public class ItemSlingshot extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(player.capabilities.isCreativeMode || PlayerHelper.hasAmmo(player, AMMO_FUNC)) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
@@ -38,12 +38,13 @@ public class ItemSpark extends ItemMod implements ICraftAchievement, IManaGiving
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xv, float yv, float zv) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof ISparkAttachable) {
ISparkAttachable attach = (ISparkAttachable) tile;
ItemStack stack = player.getHeldItem(hand);
if(attach.canAttachSpark(stack) && attach.getAttachedSpark() == null) {
stack.stackSize--;
stack.shrink(1);
if(!world.isRemote) {
EntitySpark spark = new EntitySpark(world);
spark.setPosition(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5);
@@ -97,7 +97,8 @@ public class ItemSpawnerMover extends ItemMod {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
ItemStack itemstack = player.getHeldItem(hand);
if(getEntityId(itemstack) == null) {
if(world.getBlockState(pos).getBlock().equals(Blocks.MOB_SPAWNER)) {
TileEntity te = world.getTileEntity(pos);
@@ -130,17 +131,17 @@ public class ItemSpawnerMover extends ItemMod {
pos = pos.offset(side);
}
if(itemstack.stackSize == 0) {
if(itemstack.isEmpty()) {
return false;
} else if(!player.canPlayerEdit(pos, side, itemstack)) {
return false;
} else if(world.canBlockBePlaced(Blocks.MOB_SPAWNER, pos, false, side, null, itemstack)) {
} else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) {
int meta = this.getMetadata(itemstack.getMetadata());
IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player);
if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) {
world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F);
--itemstack.stackSize;
itemstack.shrink(1);
player.renderBrokenItemStack(itemstack);
player.addStat(ModAchievements.spawnerMoverUse, 1);
for(int i = 0; i < 100; i++)
@@ -39,7 +39,8 @@ public class ItemTemperanceStone extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int dmg = stack.getItemDamage();
stack.setItemDamage(~dmg & 1);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 0.3F, 0.1F);
@@ -58,16 +58,18 @@ public class ItemThornChakram extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote) {
ItemStack copy = stack.copy();
copy.stackSize = 1;
copy.setCount(1);
EntityThornChakram c = new EntityThornChakram(world, player, copy);
c.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
c.setFire(stack.getItemDamage() != 0);
world.spawnEntity(c);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
--stack.stackSize;
stack.shrink(1);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
@@ -75,24 +75,25 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
Block block = world.getBlockState(pos).getBlock();
BlockPos boundTile = getBoundTile(par1ItemStack);
BlockPos boundTile = getBoundTile(stack);
if(boundTile.getY() != -1 && player.isSneaking() && !pos.equals(boundTile)) {
TileEntity tile = world.getTileEntity(boundTile);
if(tile instanceof IWandBindable) {
if(((IWandBindable) tile).bindTo(player, par1ItemStack, pos, side)) {
if(((IWandBindable) tile).bindTo(player, stack, pos, side)) {
Vector3 orig = new Vector3(boundTile.getX() + 0.5, boundTile.getY() + 0.5, boundTile.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
doParticleBeam(world, orig, end);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, boundTile);
setBoundTile(par1ItemStack, UNBOUND_POS);
setBoundTile(stack, UNBOUND_POS);
}
return EnumActionResult.SUCCESS;
} else setBoundTile(par1ItemStack, UNBOUND_POS);
} else setBoundTile(stack, UNBOUND_POS);
} else if(player.isSneaking()) {
block.rotateBlock(world, pos, side);
if(world.isRemote)
@@ -129,10 +130,10 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem {
boolean bindable = tile instanceof IWandBindable;
boolean wanded;
if(getBindMode(par1ItemStack) && bindable && player.isSneaking() && ((IWandBindable) tile).canSelect(player, par1ItemStack, pos, side)) {
if(getBindMode(stack) && bindable && player.isSneaking() && ((IWandBindable) tile).canSelect(player, stack, pos, side)) {
if(boundTile.equals(pos))
setBoundTile(par1ItemStack, UNBOUND_POS);
else setBoundTile(par1ItemStack, pos);
setBoundTile(stack, UNBOUND_POS);
else setBoundTile(stack, pos);
if(world.isRemote)
player.swingArm(hand);
@@ -140,7 +141,7 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem {
wanded = true;
} else {
wanded = ((IWandable) block).onUsedByWand(player, par1ItemStack, world, pos, side);
wanded = ((IWandable) block).onUsedByWand(player, stack, world, pos, side);
if(wanded && world.isRemote)
player.swingArm(hand);
}
@@ -196,7 +197,8 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote && player.isSneaking()) {
setBindMode(stack, !getBindMode(stack));
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.ding, SoundCategory.PLAYERS, 0.1F, 1F);
@@ -31,9 +31,9 @@ public class ItemVineBall extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
if(!player.capabilities.isCreativeMode)
--par1ItemStack.stackSize;
player.getHeldItem(hand).shrink(1);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
@@ -43,7 +43,7 @@ public class ItemVineBall extends ItemMod {
world.spawnEntity(ball);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
}
@@ -10,10 +10,6 @@
*/
package vazkii.botania.common.item;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.creativetab.CreativeTabs;
@@ -22,8 +18,11 @@ import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AbstractAttributeMap;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.passive.AbstractChestHorse;
import net.minecraft.entity.passive.AbstractHorse;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.HorseType;
import net.minecraft.entity.passive.EntitySkeletonHorse;
import net.minecraft.entity.passive.EntityZombieHorse;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
@@ -55,43 +54,46 @@ public class ItemVirus extends ItemMod {
}
@Override
public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer player, EntityLivingBase par3EntityLivingBase, EnumHand hand) {
if(par3EntityLivingBase instanceof EntityHorse) {
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase living, EnumHand hand) {
if(living instanceof EntityHorse || living instanceof AbstractChestHorse) {
if(player.world.isRemote)
return true;
EntityHorse horse = (EntityHorse) par3EntityLivingBase;
if(horse.getType() != HorseType.ZOMBIE && horse.getType() != HorseType.SKELETON && horse.isTame()) {
AbstractHorse horse = (AbstractHorse) living;
if(horse.isTame()) {
IItemHandler inv = horse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
ItemStack saddle = inv.getStackInSlot(0);
for (int i = 1; i < inv.getSlots(); i++)
if(inv.getStackInSlot(i) != null)
if(!inv.getStackInSlot(i).isEmpty())
horse.entityDropItem(inv.getStackInSlot(i), 0);
if (horse.isChested())
if (horse instanceof AbstractChestHorse && ((AbstractChestHorse) horse).hasChest())
horse.entityDropItem(new ItemStack(Blocks.CHEST), 0);
horse.setType(par1ItemStack.getItemDamage() == 0 ? HorseType.ZOMBIE : HorseType.SKELETON);
horse.setDead();
AbstractHorse newHorse = stack.getItemDamage() == 0 ? new EntityZombieHorse(player.world) : new EntitySkeletonHorse(player.world);
newHorse.posX = horse.posX;
newHorse.posY = horse.posY;
newHorse.posZ = horse.posZ;
newHorse.rotationPitch = horse.rotationPitch;
newHorse.rotationYaw = horse.rotationYaw;
player.world.spawnEntity(newHorse);
// Reinit the horse chest to the right new size
Method m = ReflectionHelper.findMethod(EntityHorse.class, horse, LibObfuscation.INIT_HORSE_CHEST);
try {
m.invoke(horse);
} catch (IllegalAccessException | InvocationTargetException ignored) {}
// Put the saddle back
horse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).insertItem(0, saddle, false);
newHorse.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).insertItem(0, saddle, false);
AbstractAttributeMap attributes = horse.getAttributeMap();
AbstractAttributeMap attributes = newHorse.getAttributeMap();
IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED);
IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH);
health.applyModifier(new AttributeModifier("Ermergerd Virus D:", health.getBaseValue(), 0));
movementSpeed.applyModifier(new AttributeModifier("Ermergerd Virus D:", movementSpeed.getBaseValue(), 0));
IAttributeInstance jumpHeight = attributes.getAttributeInstance(ReflectionHelper.getPrivateValue(EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH));
jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
horse.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0F + par3EntityLivingBase.world.rand.nextFloat(), par3EntityLivingBase.world.rand.nextFloat() * 0.7F + 1.3F);
horse.spawnExplosionParticle();
newHorse.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 1.0F + living.world.rand.nextFloat(), living.world.rand.nextFloat() * 0.7F + 1.3F);
newHorse.spawnExplosionParticle();
par1ItemStack.stackSize--;
stack.shrink(1);
return true;
}
}
@@ -104,10 +106,10 @@ public class ItemVirus extends ItemMod {
if(entity.isRiding() && entity.getRidingEntity() instanceof EntityLivingBase)
entity = (EntityLivingBase) entity.getRidingEntity();
if(entity instanceof EntityHorse && event.getSource() == DamageSource.fall) {
EntityHorse horse = (EntityHorse) entity;
if((horse.getType() == HorseType.ZOMBIE || horse.getType() == HorseType.SKELETON) && horse.isTame())
event.setCanceled(true);
if(entity instanceof EntityZombieHorse || entity instanceof EntitySkeletonHorse
&& event.getSource() == DamageSource.FALL
&& ((AbstractHorse) entity).isTame()) {
event.setCanceled(true);
}
}
@@ -33,7 +33,8 @@ public class ItemWorldSeed extends ItemMod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
BlockPos coords = world.getSpawnPoint();
if(MathHelper.pointDistanceSpace(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, player.posX, player.posY, player.posZ) > 24) {
@@ -48,7 +49,7 @@ public class ItemWorldSeed extends ItemMod {
for(int i = 0; i < 50; i++)
Botania.proxy.sparkleFX(player.posX + Math.random() * player.width, player.posY - 1.6 + Math.random() * player.height, player.posZ + Math.random() * player.width, 0.25F, 1F, 0.25F, 1F, 10);
stack.stackSize--;
stack.shrink(1);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@@ -76,11 +76,12 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Nonnull
@Override
public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World world, EntityLivingBase living) {
if(!world.isRemote) {
@@ -101,7 +102,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem, IPickup
return baseItem.copy();
else {
ItemStack copy = stack.copy();
copy.stackSize = 0;
copy.setCount(0);
return copy;
}
}
@@ -57,8 +57,8 @@ public abstract class ItemElementiumArmor extends ItemManasteelArmor implements
@Override
public boolean hasArmorSetItem(EntityPlayer player, int i) {
ItemStack stack = player.inventory.armorInventory[3 - i];
if(stack == null)
ItemStack stack = player.inventory.armorInventory.get(3 - i);
if(stack.isEmpty())
return false;
switch(i) {
@@ -202,8 +202,8 @@ public class ItemManasteelArmor extends ItemArmor implements ISpecialArmor, IMan
}
public boolean hasArmorSetItem(EntityPlayer player, int i) {
ItemStack stack = player.inventory.armorInventory[3 - i];
if(stack == null)
ItemStack stack = player.inventory.armorInventory.get(3 - i);
if(stack.isEmpty())
return false;
switch(i) {
@@ -85,7 +85,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchi
@Override
public boolean hasArmorSetItem(EntityPlayer player, int i) {
ItemStack stack = player.inventory.armorInventory[3 - i];
ItemStack stack = player.inventory.armorInventory.get(3 - i);
if(stack == null)
return false;
@@ -84,8 +84,8 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor {
@Override
public boolean hasArmorSetItem(EntityPlayer player, int i) {
ItemStack stack = player.inventory.armorInventory[3 - i];
if(stack == null)
ItemStack stack = player.inventory.armorInventory.get(3 - i);
if(stack.isEmpty())
return false;
switch(i) {
@@ -58,25 +58,26 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!EntityDoppleganger.isTruePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
ItemStack toEquip = stack.copy();
toEquip.stackSize = 1;
toEquip.setCount(1);
if(canEquip(toEquip, player)) {
IInventory baubles = BaublesApi.getBaubles(player);
for(int i = 0; i < baubles.getSizeInventory(); i++) {
if(baubles.isItemValidForSlot(i, toEquip)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if(stackInSlot == null || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
if(stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
if(!world.isRemote) {
baubles.setInventorySlotContents(i, toEquip);
stack.stackSize--;
stack.shrink(1);
}
if(stackInSlot != null) {
if(!stackInSlot.isEmpty()) {
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, player);
return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot.copy());
}
@@ -158,7 +159,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true);
if(cmp == null)
return null;
return ItemStack.loadItemStackFromNBT(cmp);
return new ItemStack(cmp);
}
@Override
@@ -85,7 +85,8 @@ public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem, IModel
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, @Nonnull World world, EntityPlayer player, @Nonnull EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
// Copy from superclass with our own check
boolean flag = canFire(stack, player);
ActionResult<ItemStack> ret = ForgeEventFactory.onArrowNock(stack, world, player, hand, flag);
@@ -4,9 +4,11 @@ import java.util.Random;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.AbstractSkeleton;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityWitherSkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
@@ -40,8 +42,8 @@ public class ItemElementiumAxe extends ItemManasteelAxe {
Random rand = event.getEntityLiving().world.rand;
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, weapon);
if(event.getEntityLiving() instanceof EntitySkeleton && rand.nextInt(26) <= 3 + looting)
addDrop(event, new ItemStack(Items.SKULL, 1, ((EntitySkeleton) event.getEntityLiving()).getSkeletonType().ordinal()));
if(event.getEntityLiving() instanceof AbstractSkeleton && rand.nextInt(26) <= 3 + looting)
addDrop(event, new ItemStack(Items.SKULL, 1, event.getEntityLiving() instanceof EntityWitherSkeleton ? 1 : 0));
else if(event.getEntityLiving() instanceof EntityZombie && !(event.getEntityLiving() instanceof EntityPigZombie) && rand.nextInt(26) <= 2 + 2 * looting)
addDrop(event, new ItemStack(Items.SKULL, 1, 2));
else if(event.getEntityLiving() instanceof EntityCreeper && rand.nextInt(26) <= 2 + 2 * looting)
@@ -49,9 +49,9 @@ public class ItemElementiumShears extends ItemManasteelShears {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -88,13 +88,16 @@ public class ItemManasteelAxe extends ItemAxe implements IManaUsingItem, ISortab
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != null && SAPLING_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
EnumActionResult did = stackAt.getItem().onItemUse(stackAt, player, world, pos, hand, side, sx, sy, sz);
if(stackAt.stackSize == 0)
player.inventory.setInventorySlotContents(i, null);
if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
ItemStack saveHeldStack = player.getHeldItem(hand);
player.setHeldItem(hand, stackAt); // todo 1.11 test if this works
EnumActionResult did = stackAt.getItem().onItemUse(player, world, pos, hand, side, sx, sy, sz);
player.setHeldItem(hand, saveHeldStack);
if(stackAt.isEmpty())
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.SAPLING), SAPLING_PATTERN);
return did;
@@ -84,13 +84,14 @@ public class ItemManasteelPick extends ItemPickaxe implements IManaUsingItem, IS
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != null && TORCH_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
EnumActionResult did = stackAt.getItem().onItemUse(stackAt, player, world, pos, hand, side, sx, sy, sz);
if(stackAt.stackSize == 0)
player.inventory.setInventorySlotContents(i, null);
if(!stackAt.isEmpty() && TORCH_PATTERN.matcher(stackAt.getItem().getUnlocalizedName()).find()) {
ItemStack saveHeldStack = player.getHeldItem(hand);
player.setHeldItem(hand, stackAt); // todo 1.11 test if this works
EnumActionResult did = stackAt.getItem().onItemUse(player, world, pos, hand, side, sx, sy, sz);
player.setHeldItem(hand, saveHeldStack);
ItemsRemainingRenderHandler.set(player, new ItemStack(Blocks.TORCH), TORCH_PATTERN);
return did;
@@ -84,7 +84,9 @@ public class ItemManasteelShovel extends ItemSpade implements IManaUsingItem, IS
@Nonnull
@Override
public EnumActionResult onItemUse(@Nonnull ItemStack stack, EntityPlayer player, @Nonnull World world, BlockPos pos, EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer player, @Nonnull World world, BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if(!player.canPlayerEdit(pos, side, stack))
return EnumActionResult.PASS;
else {
@@ -105,23 +105,25 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
getMana(par1ItemStack);
int level = getLevel(par1ItemStack);
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
getMana(stack);
int level = getLevel(stack);
if(level != 0) {
setEnabled(par1ItemStack, !isEnabled(par1ItemStack));
setEnabled(stack, !isEnabled(stack));
if(!world.isRemote)
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.terraPickMode, SoundCategory.PLAYERS, 0.5F, 0.4F);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
return player.isSneaking() ? super.onItemUse(stack, player, world, pos, hand, side, sx, sy, sz)
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float sx, float sy, float sz) {
return player.isSneaking() ? super.onItemUse(player, world, pos, hand, side, sx, sy, sz)
: EnumActionResult.PASS;
}
@@ -58,7 +58,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
@SubscribeEvent
public void leftClick(PlayerInteractEvent.LeftClickEmpty evt) {
if (evt.getItemStack() != null
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == this) {
PacketHandler.sendToServer(new PacketLeftClick());
}
@@ -72,7 +72,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
}
public void trySpawnBurst(EntityPlayer player) {
if (player.getHeldItemMainhand() != null
if (!player.getHeldItemMainhand().isEmpty()
&& player.getHeldItemMainhand().getItem() == this
&& player.getCooledAttackStrength(0) == 1) {
EntityManaBurst burst = getBurst(player, player.getHeldItemMainhand());
@@ -133,7 +133,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
float damage = 4F + BotaniaAPI.terrasteelToolMaterial.getDamageVsEntity();
if(!burst.isFake() && !entity.world.isRemote) {
EntityPlayer player = living.world.getPlayerEntityByName(attacker);
living.attackEntityFrom(player == null ? DamageSource.magic : DamageSource.causePlayerDamage(player), damage);
living.attackEntityFrom(player == null ? DamageSource.MAGIC : DamageSource.causePlayerDamage(player), damage);
entity.setDead();
break;
}
@@ -299,8 +299,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
@Override
public ItemStack getCompositeLens(ItemStack stack) {
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false);
ItemStack lens = ItemStack.loadItemStackFromNBT(cmp);
return lens;
return new ItemStack(cmp);
}
@Override
@@ -37,7 +37,7 @@ public class LensDamage extends Lens {
if(mana >= 16) {
burst.setMana(mana - 16);
if(!burst.isFake())
living.attackEntityFrom(DamageSource.magic, 8);
living.attackEntityFrom(DamageSource.MAGIC, 8);
break;
}
}
@@ -39,13 +39,14 @@ public class ItemDye extends Item16Colors {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
Block block = world.getBlockState(pos).getBlock();
EnumDyeColor color = EnumDyeColor.byMetadata(par1ItemStack.getItemDamage());
EnumDyeColor color = EnumDyeColor.byMetadata(stack.getItemDamage());
if(block == Blocks.WOOL && color != world.getBlockState(pos).getValue(BlockColored.COLOR)
|| block == Blocks.CARPET && color != world.getBlockState(pos).getValue(BlockCarpet.COLOR)) {
world.setBlockState(pos, world.getBlockState(pos).withProperty(block == Blocks.WOOL ? BlockColored.COLOR : BlockCarpet.COLOR, color), 1 | 2);
par1ItemStack.stackSize--;
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -54,7 +55,7 @@ public class ItemDye extends Item16Colors {
IManaPool pool = (IManaPool) tile;
if(color != pool.getColor()) {
pool.setColor(color);
par1ItemStack.stackSize--;
stack.shrink(1);
return EnumActionResult.SUCCESS;
}
}
@@ -70,7 +71,7 @@ public class ItemDye extends Item16Colors {
if(!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) {
entitysheep.setFleeceColor(i);
--stack.stackSize;
stack.shrink(1);
}
return true;
@@ -60,7 +60,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
ItemStack stack = event.getItemStack();
boolean correctStack = stack != null && stack.getItem() == Items.GLASS_BOTTLE;
boolean correctStack = !stack.isEmpty() && stack.getItem() == Items.GLASS_BOTTLE;
boolean ender = event.getWorld().provider.getDimension() == 1;
if(correctStack && ender) {
@@ -76,9 +76,9 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
event.getEntityPlayer().openContainer.detectAndSendChanges();
}
stack.stackSize--;
if(stack.stackSize == 0)
event.getEntityPlayer().setHeldItem(event.getHand(), null);
stack.shrink(1);
if(stack.isEmpty())
event.getEntityPlayer().setHeldItem(event.getHand(), ItemStack.EMPTY);
event.getWorld().playSound(null, event.getPos(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.5F, 1F);
event.setCanceled(true);
@@ -88,25 +88,28 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(par1ItemStack.getItemDamage() == 4 || par1ItemStack.getItemDamage() == 14)
return EntityDoppleganger.spawn(player, par1ItemStack, world, pos, par1ItemStack.getItemDamage() == 14) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
else if(par1ItemStack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(par1ItemStack, world, pos, player)) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if(stack.getItemDamage() == 4 || stack.getItemDamage() == 14)
return EntityDoppleganger.spawn(player, stack, world, pos, stack.getItemDamage() == 14) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
else if(stack.getItemDamage() == 20 && net.minecraft.item.ItemDye.applyBonemeal(stack, world, pos, player)) {
if(!world.isRemote)
world.playEvent(2005, pos, 0);
return EnumActionResult.SUCCESS;
}
return super.onItemUse(par1ItemStack, player, world, pos, hand, side, par8, par9, par10);
return super.onItemUse(player, world, pos, hand, side, par8, par9, par10);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
if(par1ItemStack.getItemDamage() == 15) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(stack.getItemDamage() == 15) {
if(!player.capabilities.isCreativeMode)
--par1ItemStack.stackSize;
stack.shrink(1);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
@@ -116,10 +119,10 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
world.spawnEntity(b);
}
else player.swingArm(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
@@ -39,7 +39,7 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent {
@Nonnull
@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) {
// Copy of ItemBlock.onItemUse
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
@@ -49,7 +49,8 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent {
pos = pos.offset(facing);
}
if (stack.stackSize != 0 && player.canPlayerEdit(pos, facing, stack) && world.canBlockBePlaced(ModBlocks.buriedPetals, pos, false, facing, null, stack))
ItemStack stack = player.getHeldItem(hand);
if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null))
{
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player);
@@ -58,7 +59,7 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent {
{
SoundType soundtype = ModBlocks.buriedPetals.getSoundType();
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
@@ -52,7 +52,9 @@ public class ItemDice extends ItemRelic {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(isRightPlayer(player, stack) && !player.world.isRemote) {
int moonPhase = world.provider.getMoonPhase(world.getWorldTime());
int relic = SIDES_FOR_MOON_PHASES[moonPhase];
@@ -73,7 +75,7 @@ public class ItemDice extends ItemRelic {
if(hasRelicAlready(player, relic)) {
player.sendMessage(new TextComponentTranslation("botaniamisc.dudDiceRoll", relic + 1).setStyle(new Style().setColor(TextFormatting.DARK_GREEN)));
stack.stackSize--;
stack.shrink(1);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@@ -47,7 +47,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if(player.isSneaking()) {
if(world.isRemote) {
player.swingArm(hand);
@@ -58,6 +58,7 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
Botania.proxy.wispFX(x1, y1, z1, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, -0.05F + (float) Math.random() * 0.05F);
}
} else {
ItemStack stack = player.getHeldItem(hand);
ItemNBTHelper.setInt(stack, TAG_X, pos.getX());
ItemNBTHelper.setInt(stack, TAG_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_Z, pos.getZ());
@@ -79,9 +80,9 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -50,7 +50,8 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(player.canEat(false) && isRightPlayer(player, stack)) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
@@ -44,10 +44,11 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
setCharging(par1ItemStack, true);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
ItemStack stack = player.getHeldItem(hand);
setCharging(stack, true);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Override
@@ -89,7 +89,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
int cost = Math.min(cursorCount, (int) Math.pow(Math.E, cursorCount * 0.25));
if(heldItemStack == null && player.isSneaking()) {
if(heldItemStack.isEmpty() && player.isSneaking()) {
if(originCoords.getY() == -1 && lookPos != null && lookPos.getBlockPos() != null) {
setOriginPos(lokiRing, lookPos.getBlockPos());
setCursorList(lokiRing, null);
@@ -115,13 +115,16 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
}
}
}
} else if(heldItemStack != null && lookPos != null && lookPos.getBlockPos() != null && player.isSneaking()) {
} else if(!heldItemStack.isEmpty() && lookPos != null && lookPos.getBlockPos() != null && player.isSneaking()) {
for(BlockPos cursor : cursors) {
BlockPos pos = lookPos.getBlockPos().add(cursor);
Item item = heldItemStack.getItem();
if(!player.world.isAirBlock(pos) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) {
item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.world, pos, event.getHand(), lookPos.sideHit, (float) lookPos.hitVec.xCoord - pos.getX(), (float) lookPos.hitVec.yCoord - pos.getY(), (float) lookPos.hitVec.zCoord - pos.getZ());
if(heldItemStack.stackSize == 0) {
ItemStack saveHeld = heldItemStack.copy();
item.onItemUse(player, player.world, pos, event.getHand(), lookPos.sideHit, (float) lookPos.hitVec.xCoord - pos.getX(), (float) lookPos.hitVec.yCoord - pos.getY(), (float) lookPos.hitVec.zCoord - pos.getZ());
if (player.isCreative())
player.setHeldItem(event.getHand(), saveHeld);
if(heldItemStack.isEmpty()) {
event.setCanceled(true);
return;
}
@@ -42,16 +42,16 @@ public class ItemOdinRing extends ItemRelicBauble {
super(LibItemNames.ODIN_RING);
MinecraftForge.EVENT_BUS.register(ItemOdinRing.class);
damageNegations.add(DamageSource.drown.damageType);
damageNegations.add(DamageSource.fall.damageType);
damageNegations.add(DamageSource.lava.damageType);
damageNegations.add(DamageSource.DROWN.damageType);
damageNegations.add(DamageSource.FALL.damageType);
damageNegations.add(DamageSource.LAVA.damageType);
if(ConfigHandler.ringOfOdinFireResist) {
damageNegations.add(DamageSource.inFire.damageType);
damageNegations.add(DamageSource.onFire.damageType);
damageNegations.add(DamageSource.IN_FIRE.damageType);
damageNegations.add(DamageSource.ON_FIRE.damageType);
}
damageNegations.add(DamageSource.inWall.damageType);
damageNegations.add(DamageSource.starve.damageType);
damageNegations.add(DamageSource.IN_WALL.damageType);
damageNegations.add(DamageSource.STARVE.damageType);
}
@Override
@@ -38,8 +38,8 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return ItemDirtRod.place(par1ItemStack, player, world, pos, hand, side, par8, par9, par10, Blocks.COBBLESTONE, COST, 0.3F, 0.3F, 0.3F);
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return ItemDirtRod.place(player, world, pos, hand, side, par8, par9, par10, Blocks.COBBLESTONE, COST, 0.3F, 0.3F, 0.3F);
}
@Override
@@ -57,20 +57,21 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, ICraftAchiev
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return place(par1ItemStack, player, world, pos, hand, side, par8, par9, par10, Blocks.DIRT, COST, 0.35F, 0.2F, 0.05F);
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return place(player, world, pos, hand, side, par8, par9, par10, Blocks.DIRT, COST, 0.35F, 0.2F, 0.05F);
}
public static EnumActionResult place(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) {
if(ManaItemHandler.requestManaExactForTool(par1ItemStack, player, cost, false)) {
public static EnumActionResult place(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) {
int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
if(entities == 0) {
ItemStack stackToPlace = new ItemStack(block);
stackToPlace.onItemUse(player, world, pos, hand, side, par8, par9, par10);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, cost, true);
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, cost, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(pos.getX() + side.getFrontOffsetX() + Math.random(), pos.getY() + side.getFrontOffsetY() + Math.random(), pos.getZ() + side.getFrontOffsetZ() + Math.random(), r, g, b, 1F, 5);
return EnumActionResult.SUCCESS;
@@ -51,7 +51,8 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer p, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer p, @Nonnull EnumHand hand) {
ItemStack stack = p.getHeldItem(hand);
if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) {
if(world.isRemote) {
int range = IManaProficiencyArmor.Helper.hasProficiency(p, stack) ? 20 : 15;
@@ -76,7 +76,8 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
IBlockState wstate = world.getBlockState(pos);
if(player.isSneaking()) {
@@ -85,23 +86,23 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(BlockCamo.isValidBlock(wstate)) {
Item item = Item.getItemFromBlock(wstate.getBlock());
setBlock(par1ItemStack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
player.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, par1ItemStack);
setBlock(stack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
player.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, stack);
displayRemainderCounter(player, par1ItemStack);
displayRemainderCounter(player, stack);
return EnumActionResult.SUCCESS;
}
}
} else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) {
Block block = getBlock(par1ItemStack);
int meta = getBlockMeta(par1ItemStack);
List<BlockPos> swap = getBlocksToSwap(world, par1ItemStack, block.getStateFromMeta(meta), pos, null);
} else if(canExchange(stack) && !ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
Block block = getBlock(stack);
int meta = getBlockMeta(stack);
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), pos, null);
if(swap.size() > 0) {
ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true);
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, pos.getX());
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, pos.getY());
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, pos.getZ());
setTargetBlock(par1ItemStack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, true);
ItemNBTHelper.setInt(stack, TAG_SELECT_X, pos.getX());
ItemNBTHelper.setInt(stack, TAG_SELECT_Y, pos.getY());
ItemNBTHelper.setInt(stack, TAG_SELECT_Z, pos.getZ());
setTargetBlock(stack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
if(world.isRemote)
player.swingArm(hand);
}
@@ -113,7 +114,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
@SubscribeEvent
public void onLeftClick(PlayerInteractEvent.LeftClickBlock event) {
ItemStack stack = event.getItemStack();
if(stack != null && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, false)) {
if(!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, false)) {
if(exchange(event.getWorld(), event.getEntityPlayer(), event.getPos(), stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack))))
ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, true);
}
@@ -257,9 +258,9 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta) {
ItemStack retStack = invStack.copy();
if(doit) {
invStack.stackSize--;
if(invStack.stackSize == 0)
inv.setInventorySlotContents(i, null);
invStack.shrink(1);
if(invStack.isEmpty())
inv.setInventorySlotContents(i, ItemStack.EMPTY);
}
return retStack;
}
@@ -307,12 +308,12 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
int count = 0;
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack invStack = inv.getStackInSlot(i);
if(invStack == null)
if(invStack.isEmpty())
continue;
Item item = invStack.getItem();
if(item == Item.getItemFromBlock(block) && invStack.getItemDamage() == meta)
count += invStack.stackSize;
count += invStack.getCount();
if(item instanceof IBlockProvider) {
IBlockProvider prov = (IBlockProvider) item;
@@ -48,15 +48,16 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
EntityFlameRing entity = new EntityFlameRing(player.world);
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
player.world.spawnEntity(entity);
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack) ? COOLDOWN / 2 : COOLDOWN);
player.getCooldownTracker().setCooldown(this, IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? COOLDOWN / 2 : COOLDOWN);
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true);
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BLAZE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
}
@@ -89,7 +89,8 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1);
int ticksCooldown = ItemNBTHelper.getInt(stack, TAG_TICKS_COOLDOWN, 0);
double length = ItemNBTHelper.getDouble(stack, TAG_DIST, -1);
@@ -90,9 +90,9 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -58,8 +58,9 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, MANA_COST, false)) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false)) {
Block place = ModBlocks.bifrost;
Vector3 vector = new Vector3(player.getLookVec()).normalize();
@@ -74,7 +75,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
BlockPos.MutableBlockPos lastChecker = new BlockPos.MutableBlockPos();
int count = 0;
boolean prof = IManaProficiencyArmor.Helper.hasProficiency(player, par1ItemStack);
boolean prof = IManaProficiencyArmor.Helper.hasProficiency(player, stack);
int maxlen = prof ? 160 : 100;
int time = prof ? (int) (TIME * 1.6) : TIME;
@@ -116,12 +117,12 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
if(count > 0) {
world.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F);
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, MANA_COST, false);
ManaItemHandler.requestManaExactForTool(stack, player, MANA_COST, false);
player.getCooldownTracker().setCooldown(this, TIME);
}
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Nonnull
@@ -37,7 +37,8 @@ public class ItemSkyDirtRod extends ItemDirtRod {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) {
Vector3 playerVec = Vector3.fromEntityCenter(player);
Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3);
@@ -53,7 +54,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
ItemStack stackToPlace = new ItemStack(Blocks.DIRT);
stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), hand, EnumFacing.DOWN, 0F, 0F, 0F);
if(stackToPlace.stackSize == 0) {
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(x + Math.random(), y + Math.random(), z + Math.random(), 0.35F, 0.2F, 0.05F, 1F, 5);
@@ -64,9 +64,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
@Override
@@ -101,9 +101,9 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
private void terraform(ItemStack par1ItemStack, World world, EntityPlayer player) {
@@ -93,18 +93,19 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
int meta = par1ItemStack.getItemDamage();
if(meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) {
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
int meta = stack.getItemDamage();
if(meta != 0 || ManaItemHandler.requestManaExactForTool(stack, player, COST, false)) {
player.setActiveHand(hand);
if(meta == 0) {
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true);
setFlying(par1ItemStack, true);
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
setFlying(stack, true);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Nonnull
@@ -29,8 +29,9 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false) && !world.provider.doesWaterVaporize()) {
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stack = player.getHeldItem(hand);
if(ManaItemHandler.requestManaExactForTool(stack, player, COST, false) && !world.provider.doesWaterVaporize()) {
// Adapted from bucket code
RayTraceResult mop = rayTrace(world, player, false);
@@ -39,8 +40,8 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
if(!world.isBlockModifiable(player, hitPos))
return EnumActionResult.FAIL;
BlockPos placePos = hitPos.offset(mop.sideHit);
if(player.canPlayerEdit(placePos, mop.sideHit, par1ItemStack)) {
if (ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true)
if(player.canPlayerEdit(placePos, mop.sideHit, stack)) {
if (ManaItemHandler.requestManaExactForTool(stack, player, COST, true)
&& ((ItemBucket) Items.WATER_BUCKET).tryPlaceContainedLiquid(player, world, placePos)) {
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(pos.getX() + side.getFrontOffsetX() + Math.random(), pos.getY() + side.getFrontOffsetY() + Math.random(), pos.getZ() + side.getFrontOffsetZ() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);