A lot of items. Rods, and lenses.

This commit is contained in:
Vincent Lee committed 2016-03-18 16:51:21 -05:00
1 parent cfbf2cc538
commit 1c608d4636
59 files changed
+568 -388

No files matched your search

@@ -50,6 +50,9 @@ public final class BotaniaSoundEvents {
public static final SoundEvent unholyCloak = getRegisteredSoundEvent("botania:unholyCloak");
public static final SoundEvent way = getRegisteredSoundEvent("botania:way");
public static final SoundEvent gaiaMusic1 = getRegisteredSoundEvent("botania:music.gaia1");
public static final SoundEvent gaiaMusic2 = getRegisteredSoundEvent("botania:music.gaia2");
private static SoundEvent getRegisteredSoundEvent(String name) {
return SoundEvent.soundEventRegistry.getObject(new ResourceLocation(name));
}
@@ -15,6 +15,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockVine;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.network.datasync.DataParameter;
@@ -38,8 +39,8 @@ public class EntityVineBall extends EntityThrowable {
gravity = false;
}
public EntityVineBall(EntityPlayer player, boolean gravity) {
super(player.worldObj, player);
public EntityVineBall(EntityLivingBase thrower, boolean gravity) {
super(thrower.worldObj, thrower);
this.gravity = gravity;
}
@@ -14,6 +14,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -31,9 +34,9 @@ public class ItemBaubleBox extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
player.openGui(Botania.instance, LibGuiIDs.BAUBLE_BOX, world, 0, 0, 0);
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@@ -2,10 +2,10 @@
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*
* File Created @ [Mar 31, 2015, 11:04:12 PM (GMT)]
*/
package vazkii.botania.common.item;
@@ -19,12 +19,18 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
@@ -54,18 +60,19 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(getBlock(par1ItemStack) != Blocks.air && par3EntityPlayer.isSneaking()) {
int dmg = par1ItemStack.getItemDamage();
par1ItemStack.setItemDamage(~dmg & 1);
par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
par3EntityPlayer.playSound(SoundEvents.entity_experience_orb_pickup, 0.3F, 0.1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
IBlockState state = par3World.getBlockState(pos);
boolean set = setBlock(par1ItemStack, state.getBlock(), state.getBlock().getMetaFromState(state));
@@ -109,15 +116,15 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
ItemStack stack = new ItemStack(bBlock, 1, bmeta);
ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack));
Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, pos, side, par8, par9, par10);
Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10);
set = true;
}
}
}
}
par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
return set;
par2EntityPlayer.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, par1ItemStack);
return set ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
@Override
@@ -22,6 +22,7 @@ import net.minecraft.util.text.translation.I18n;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.item.IManaDissolvable;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibItemNames;
@@ -78,7 +79,7 @@ public class ItemBlackLotus extends ItemMod implements IManaDissolvable {
Botania.proxy.wispFX(item.worldObj, item.posX, tile.getPos().getY() + 0.5F, item.posZ, r, g, b, s, mx, my, mz);
}
item.worldObj.playSoundAtEntity(item, "botania:blackLotus", 0.5F, t2 ? 0.1F : 1F);
item.playSound(BotaniaSoundEvents.blackLotus, 0.5F, t2 ? 0.1F : 1F);
}
@Override
@@ -20,13 +20,20 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.entity.EntityPixie;
import vazkii.botania.common.entity.EntitySignalFlare;
@@ -42,75 +49,77 @@ public class ItemBottledMana extends ItemMod {
setMaxDamage(6);
}
public void effect(EntityPlayer player, int id) {
public void effect(EntityLivingBase living, int id) {
switch(id) {
case 0 : { // Random motion
player.motionX = (Math.random() - 0.5) * 3;
player.motionZ = (Math.random() - 0.5) * 3;
living.motionX = (Math.random() - 0.5) * 3;
living.motionZ = (Math.random() - 0.5) * 3;
break;
}
case 1 : { // Water
if(!player.worldObj.isRemote && !player.worldObj.provider.doesWaterVaporize())
player.worldObj.setBlockState(new BlockPos(player), Blocks.flowing_water.getDefaultState());
if(!living.worldObj.isRemote && !living.worldObj.provider.doesWaterVaporize())
living.worldObj.setBlockState(new BlockPos(living), Blocks.flowing_water.getDefaultState());
break;
}
case 2 : { // Set on Fire
if(!player.worldObj.isRemote)
player.setFire(4);
if(!living.worldObj.isRemote)
living.setFire(4);
break;
}
case 3 : { // Mini Explosion
if(!player.worldObj.isRemote)
player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ, 0.25F, false);
if(!living.worldObj.isRemote)
living.worldObj.createExplosion(null, living.posX, living.posY, living.posZ, 0.25F, false);
break;
}
case 4 : { // Mega Jump
if(!player.worldObj.provider.doesWaterVaporize()) {
if(!player.worldObj.isRemote)
player.addPotionEffect(new PotionEffect(Potion.resistance.id, 300, 5));
player.motionY = 6;
if(!living.worldObj.provider.doesWaterVaporize()) {
if(!living.worldObj.isRemote)
living.addPotionEffect(new PotionEffect(MobEffects.resistance, 300, 5));
living.motionY = 6;
}
break;
}
case 5 : { // Randomly set HP
if(!player.worldObj.isRemote)
player.setHealth(player.worldObj.rand.nextInt(19) + 1);
if(!living.worldObj.isRemote)
living.setHealth(living.worldObj.rand.nextInt(19) + 1);
break;
}
case 6 : { // Lots O' Hearts
if(!player.worldObj.isRemote)
player.addPotionEffect(new PotionEffect(Potion.absorption.id, 20 * 60 * 2, 9));
if(!living.worldObj.isRemote)
living.addPotionEffect(new PotionEffect(MobEffects.absorption, 20 * 60 * 2, 9));
break;
}
case 7 : { // All your inventory is belong to us
if(!player.worldObj.isRemote)
if(!living.worldObj.isRemote && living instanceof EntityPlayer) {
EntityPlayer player = ((EntityPlayer) living);
for(int i = 0; i < player.inventory.getSizeInventory(); i++)
if(i != player.inventory.currentItem) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != null)
player.dropPlayerItemWithRandomChoice(stackAt, true);
player.entityDropItem(stackAt, 0);
player.inventory.setInventorySlotContents(i, null);
}
}
break;
}
case 8 : { // Break your neck
player.rotationPitch = (float) Math.random() * 360F;
player.rotationYaw = (float) Math.random() * 180F;
living.rotationPitch = (float) Math.random() * 360F;
living.rotationYaw = (float) Math.random() * 180F;
break;
}
case 9 : { // Highest Possible
int x = MathHelper.floor_double(player.posX);
MathHelper.floor_double(player.posY);
int z = MathHelper.floor_double(player.posZ);
int x = MathHelper.floor_double(living.posX);
MathHelper.floor_double(living.posY);
int z = MathHelper.floor_double(living.posZ);
for(int i = 256; i > 0; i--) {
Block block = player.worldObj.getBlockState(new BlockPos(x, i, z)).getBlock();
if(!block.isAir(player.worldObj, new BlockPos(x, i, z))) {
if(player instanceof EntityPlayerMP) {
EntityPlayerMP mp = (EntityPlayerMP) player;
mp.playerNetServerHandler.setPlayerLocation(player.posX, i + 1.6, player.posZ, player.rotationYaw, player.rotationPitch);
Block block = living.worldObj.getBlockState(new BlockPos(x, i, z)).getBlock();
if(!block.isAir(living.worldObj.getBlockState(new BlockPos(x, i, z)), living.worldObj, new BlockPos(x, i, z))) {
if(living instanceof EntityPlayerMP) {
EntityPlayerMP mp = (EntityPlayerMP) living;
mp.playerNetServerHandler.setPlayerLocation(living.posX, i + 1.6, living.posZ, living.rotationYaw, living.rotationPitch);
}
break;
}
@@ -119,55 +128,55 @@ public class ItemBottledMana extends ItemMod {
break;
}
case 10 : { // HYPERSPEEEEEED
if(!player.worldObj.isRemote)
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 60, 200));
if(!living.worldObj.isRemote)
living.addPotionEffect(new PotionEffect(MobEffects.moveSpeed, 60, 200));
break;
}
case 11 : { // Night Vision
if(!player.worldObj.isRemote)
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 6000, 0));
if(!living.worldObj.isRemote)
living.addPotionEffect(new PotionEffect(MobEffects.nightVision, 6000, 0));
break;
}
case 12 : { // Flare
if(!player.worldObj.isRemote) {
EntitySignalFlare flare = new EntitySignalFlare(player.worldObj);
flare.setPosition(player.posX, player.posY, player.posZ);
flare.setColor(player.worldObj.rand.nextInt(16));
player.worldObj.playSoundAtEntity(player, "random.explode", 40F, (1.0F + (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
if(!living.worldObj.isRemote) {
EntitySignalFlare flare = new EntitySignalFlare(living.worldObj);
flare.setPosition(living.posX, living.posY, living.posZ);
flare.setColor(living.worldObj.rand.nextInt(16));
flare.playSound(SoundEvents.entity_generic_explode, 40F, (1.0F + (living.worldObj.rand.nextFloat() - living.worldObj.rand.nextFloat()) * 0.2F) * 0.7F);
player.worldObj.spawnEntityInWorld(flare);
living.worldObj.spawnEntityInWorld(flare);
int range = 5;
List<EntityLivingBase> entities = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
List<EntityLivingBase> entities = living.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(living.posX - range, living.posY - range, living.posZ - range, living.posX + range, living.posY + range, living.posZ + range));
for(EntityLivingBase entity : entities)
if(entity != player && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled()))
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5));
if(entity != living && (!(entity instanceof EntityPlayer) || FMLCommonHandler.instance().getMinecraftServerInstance() == null || FMLCommonHandler.instance().getMinecraftServerInstance().isPVPEnabled()))
entity.addPotionEffect(new PotionEffect(MobEffects.moveSlowdown, 50, 5));
}
break;
}
case 13 : { // Pixie Friend
if(!player.worldObj.isRemote) {
EntityPixie pixie = new EntityPixie(player.worldObj);
pixie.setPosition(player.posX, player.posY + 1.5, player.posZ);
player.worldObj.spawnEntityInWorld(pixie);
if(!living.worldObj.isRemote) {
EntityPixie pixie = new EntityPixie(living.worldObj);
pixie.setPosition(living.posX, living.posY + 1.5, living.posZ);
living.worldObj.spawnEntityInWorld(pixie);
}
break;
}
case 14 : { // Nausea + Blindness :3
if(!player.worldObj.isRemote) {
player.addPotionEffect(new PotionEffect(Potion.confusion.id, 160, 3));
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 160, 0));
if(!living.worldObj.isRemote) {
living.addPotionEffect(new PotionEffect(MobEffects.confusion, 160, 3));
living.addPotionEffect(new PotionEffect(MobEffects.blindness, 160, 0));
}
break;
}
case 15 : { // Drop own Head
if(!player.worldObj.isRemote) {
player.attackEntityFrom(DamageSource.magic, player.getHealth() - 1);
if(!living.worldObj.isRemote && living instanceof EntityPlayer) {
living.attackEntityFrom(DamageSource.magic, living.getHealth() - 1);
ItemStack stack = new ItemStack(Items.skull, 1, 3);
ItemNBTHelper.setString(stack, "SkullOwner", player.getName());
player.dropPlayerItemWithRandomChoice(stack, true);
ItemNBTHelper.setString(stack, "SkullOwner", living.getName());
living.entityDropItem(stack, 0);
}
break;
}
@@ -179,7 +188,7 @@ public class ItemBottledMana extends ItemMod {
getSeed(par1ItemStack);
}
public void randomEffect(EntityPlayer player, ItemStack stack) {
public void randomEffect(EntityLivingBase player, ItemStack stack) {
effect(player, new Random(getSeed(stack)).nextInt(16));
}
@@ -202,14 +211,14 @@ public class ItemBottledMana extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public ItemStack onItemUseFinish(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
randomEffect(par3EntityPlayer, par1ItemStack);
public ItemStack onItemUseFinish(ItemStack par1ItemStack, World par2World, EntityLivingBase living) {
randomEffect(living, par1ItemStack);
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1);
randomSeed(par1ItemStack);
@@ -24,6 +24,12 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.translation.I18n;
@@ -49,7 +55,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
}
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) {
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if(entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
String sound = null;
@@ -71,7 +77,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy());
if(player.worldObj.isRemote)
player.swingItem();
player.swingArm(hand);
return true;
}
@@ -84,7 +90,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
boolean can = isDOIT(stack);
if(!can) {
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
@@ -99,11 +105,11 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState());
((TileCacophonium) world.getTileEntity(pos)).stack = stack.copy();
stack.stackSize--;
return true;
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
@Override
@@ -125,14 +131,14 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack))
par3EntityPlayer.setItemInUse(par1ItemStack, 72000);
return par1ItemStack;
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
if(count % (isDOIT(stack) ? 20 : 6) == 0)
playSound(player.worldObj, stack, player.posX, player.posY, player.posZ, 0.9F);
}
@@ -146,8 +152,8 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
if(doit)
sound = "botania:doit";
if(sound != null && !sound.isEmpty())
world.playSoundEffect(x, y, z, sound, volume, doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F);
if(sound != null && !sound.isEmpty() && SoundEvent.soundEventRegistry.containsKey(new ResourceLocation(sound)))
world.playSound(null, x, y, z, SoundEvent.soundEventRegistry.getObject(new ResourceLocation(sound)), SoundCategory.NEUTRAL, volume, doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F);
}
private static boolean isDOIT(ItemStack stack) {
@@ -18,6 +18,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -40,7 +42,7 @@ public class ItemCorporeaSpark extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xv, float yv, float zv) {
public EnumActionResult onItemUse(ItemStack stack, 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)) {
@@ -51,11 +53,11 @@ public class ItemCorporeaSpark extends ItemMod {
spark.setMaster(true);
spark.setPosition(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5);
world.spawnEntityInWorld(spark);
world.markBlockForUpdate(pos);
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 0);
}
return true;
return EnumActionResult.SUCCESS;
}
return false;
return EnumActionResult.PASS;
}
@Override
@@ -17,6 +17,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -32,14 +34,15 @@ public class ItemCraftPattern extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemStack stack, 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 && !world.isRemote) {
if(tile != null && tile instanceof TileCraftCrate) {
TileCraftCrate crate = (TileCraftCrate) tile;
crate.pattern = stack.getItemDamage();
world.markBlockForUpdate(pos);
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
return EnumActionResult.SUCCESS;
}
return false;
return EnumActionResult.PASS;
}
@Override
@@ -32,6 +32,11 @@ import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.Achievement;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
@@ -48,6 +53,7 @@ import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.core.helper.InventoryHelper.GenericInventory;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibGuiIDs;
import vazkii.botania.common.lib.LibItemNames;
@@ -82,7 +88,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
int segment = getSegmentLookedAt(stack, player);
ItemStack itemForPos = getItemForSlot(stack, segment);
@@ -94,7 +100,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
else tryCraft(player, stack, segment, true, getFakeInv(player), true);
}
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
public static IInventory getFakeInv(EntityPlayer player) {
@@ -384,8 +390,8 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof ItemCraftingHalo)
ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, ItemCraftingHalo.class);
if(stack != null)
render(stack, player, event.partialTicks);
}
@@ -13,7 +13,12 @@ package vazkii.botania.common.item;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import vazkii.botania.api.item.IBlockProvider;
import vazkii.botania.api.mana.IManaUsingItem;
@@ -34,21 +39,22 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) {
player.displayGUIChest(player.getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.entity_endermen_teleport, SoundCategory.PLAYERS, 1F, 1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return stack;
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity) {
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity, EnumHand hand) {
if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) {
iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true);
iplayer.worldObj.playSoundAtEntity(iplayer, "mob.endermen.portal", 1F, 1F);
entity.playSound(SoundEvents.entity_endermen_teleport, 1F, 1F);
return true;
}
@@ -16,6 +16,8 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -32,7 +34,7 @@ public class ItemFertilizer extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
final int range = 3;
if(!par3World.isRemote) {
List<BlockPos> validCoords = new ArrayList<>();
@@ -65,6 +67,6 @@ public class ItemFertilizer extends ItemMod {
}
}
return true;
return EnumActionResult.SUCCESS;
}
}
@@ -18,6 +18,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -90,13 +93,13 @@ public class ItemFlowerBag extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0);
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemStack stack, 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) {
@@ -107,7 +110,7 @@ public class ItemFlowerBag extends ItemMod {
inv = new InvWrapper(((IInventory) tile));
if(inv == null)
return true;
return EnumActionResult.SUCCESS;
ItemStack[] stacks = loadStacks(stack);
ItemStack[] newStacks = new ItemStack[stacks.length];
@@ -132,9 +135,9 @@ public class ItemFlowerBag extends ItemMod {
}
}
return true;
return EnumActionResult.SUCCESS;
}
return false;
return EnumActionResult.PASS;
}
public static ItemStack[] loadStacks(ItemStack stack) {
@@ -18,6 +18,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.MathHelper;
@@ -33,82 +35,62 @@ public class ItemGaiaHead extends ItemMod {
// Copied from vanila skull itemBlock. Relevant edits are indicated.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && side != EnumFacing.DOWN)
{
side = EnumFacing.UP;
pos = pos.down();
}
if (side == EnumFacing.DOWN)
{
return false;
}
else
{
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing == EnumFacing.DOWN) {
return EnumActionResult.FAIL;
} else {
if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
facing = EnumFacing.UP;
pos = pos.down();
}
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (!flag)
{
if (!worldIn.isSideSolid(pos, side, true))
{
return false;
if (!flag) {
if (!worldIn.getBlockState(pos).getMaterial().isSolid() && !worldIn.isSideSolid(pos, facing, true)) {
return EnumActionResult.FAIL;
}
pos = pos.offset(side);
pos = pos.offset(facing);
}
if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else if (!Blocks.skull.canPlaceBlockAt(worldIn, pos))
{
return false;
}
else
{
if (!worldIn.isRemote)
{
if (!Blocks.skull.canPlaceBlockOnSide(worldIn, pos, side)) return false;
worldIn.setBlockState(pos, ModBlocks.gaiaHead.getDefaultState().withProperty(BlockSkull.FACING, side), 3); // Botania: skull -> gaia Head
if (playerIn.canPlayerEdit(pos, facing, stack) && Blocks.skull.canPlaceBlockAt(worldIn, pos)) {
if (worldIn.isRemote) {
return EnumActionResult.SUCCESS;
} else {
worldIn.setBlockState(pos, ModBlocks.gaiaHead.getDefaultState().withProperty(BlockSkull.FACING, facing), 11); // Botania - skull -> gaia head
int i = 0;
if (side == EnumFacing.UP)
{
i = MathHelper.floor_double((double)(playerIn.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
if (facing == EnumFacing.UP) {
i = MathHelper.floor_double((double) (playerIn.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
}
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntitySkull)
{
TileEntitySkull tileentityskull = (TileEntitySkull)tileentity;
if (tileentity instanceof TileEntitySkull) {
TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
if (stack.getMetadata() == 3) // Botania: Don't retrieve skins
{
// GameProfile gameprofile = null;
//
// if (stack.hasTagCompound())
// {
// NBTTagCompound nbttagcompound = stack.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 10))
// {
// gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
// }
// else if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
// }
// }
//
// tileentityskull.setPlayerProfile(gameprofile);
}
else
if (stack.getMetadata() == 3) // Botania - do not retrieve skins
{
/*GameProfile gameprofile = null;
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
{
gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
}
}
tileentityskull.setPlayerProfile(gameprofile);*/
} else {
tileentityskull.setType(stack.getMetadata());
}
@@ -117,12 +99,11 @@ public class ItemGaiaHead extends ItemMod {
}
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
return true;
} else {
return EnumActionResult.FAIL;
}
}
}
}
@@ -19,12 +19,18 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.item.IGrassHornExcempt;
@@ -71,18 +77,18 @@ public class ItemGrassHorn extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int time) {
public void onUsingTick(ItemStack stack, EntityLivingBase player, int time) {
if(time != getMaxItemUseDuration(stack) && time % 5 == 0)
breakGrass(player.worldObj, stack, stack.getItemDamage(), new BlockPos(player));
if(!player.worldObj.isRemote)
player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.block_note_basedrum, SoundCategory.BLOCKS, 1F, 0.001F);
}
public static void breakGrass(World world, ItemStack stack, int stackDmg, BlockPos srcPos) {
@@ -97,7 +103,7 @@ public class ItemGrassHorn extends ItemMod {
for(int k = -rangeY; k < rangeY + 1; k++) {
BlockPos pos = srcPos.add(i, k, j);
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, pos)) || stackDmg == 1 && block.isLeaves(world, pos) || stackDmg == 2 && block == Blocks.snow_layer)
if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, pos)) || stackDmg == 1 && block.isLeaves(world.getBlockState(pos), world, pos) || stackDmg == 2 && block == Blocks.snow_layer)
coords.add(pos);
}
@@ -27,6 +27,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -76,7 +78,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
IBlockState state = par3World.getBlockState(pos);
if((state.getBlock() == Blocks.dirt && state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT) || (state.getBlock() == Blocks.grass && par1ItemStack.getItemDamage() != 0)) {
@@ -149,9 +151,10 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
}
par1ItemStack.stackSize--;
return EnumActionResult.SUCCESS;
}
return true;
return EnumActionResult.PASS;
}
@SubscribeEvent
@@ -327,8 +330,6 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
Block aboveBlock = world.getBlockState(pos.up()).getBlock();
// Valid blocks to spread to are either dirt or grass, and do not
// have blocks which block grass growth.
@@ -338,7 +339,7 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
return (block == Blocks.dirt || block == Blocks.grass)
&& (block != Blocks.dirt || state.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT)
&& (aboveBlock.getLightOpacity(world, pos.up()) <= 1);
&& (world.getBlockState(pos.up()).getLightOpacity(world, pos.up()) <= 1);
}
}
@@ -11,10 +11,12 @@
package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.achievement.ModAchievements;
@@ -26,7 +28,7 @@ public class ItemManaCookie extends ItemFood {
public ItemManaCookie() {
super(0, 0.1F, false);
setPotionEffect(Potion.saturation.id, 1, 0, 1F);
setPotionEffect(new PotionEffect(MobEffects.saturation, 1, 0), 1F);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setUnlocalizedName(LibItemNames.MANA_COOKIE);
}
@@ -17,10 +17,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
@@ -68,9 +72,9 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
int effCd = COOLDOWN;
PotionEffect effect = par3EntityPlayer.getActivePotionEffect(Potion.digSpeed);
PotionEffect effect = par3EntityPlayer.getActivePotionEffect(MobEffects.digSpeed);
if(effect != null)
effCd -= (effect.getAmplifier() + 1) * 8;
@@ -78,7 +82,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
rotatePos(par1ItemStack);
par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F);
if(par2World.isRemote)
par3EntityPlayer.swingItem();
par3EntityPlayer.swingArm(hand);
ItemStack lens = getLens(par1ItemStack);
ItemsRemainingRenderHandler.set(lens, -2);
par1ItemStack.setItemDamage(effCd);
@@ -92,7 +96,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
par3EntityPlayer.addStat(ModAchievements.desuGun, 1);
par2World.spawnEntityInWorld(burst);
} else {
par3EntityPlayer.swingItem();
par3EntityPlayer.swingArm(hand);
par3EntityPlayer.motionX -= burst.motionX * 0.1;
par3EntityPlayer.motionY -= burst.motionY * 0.3;
par3EntityPlayer.motionZ -= burst.motionZ * 0.1;
@@ -102,7 +106,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 0.6F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
// ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN ASADA-SAN
@@ -17,12 +17,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaTooltipDisplay;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.api.wand.ICoordBoundItem;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -83,17 +88,17 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(par2EntityPlayer.isSneaking() && !par3World.isRemote) {
TileEntity tile = par3World.getTileEntity(pos);
if(tile != null && tile instanceof IManaPool) {
bindPool(par1ItemStack, tile);
par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F);
return true;
par3World.playSound(null, par2EntityPlayer.posX, par2EntityPlayer.posY, par2EntityPlayer.posZ, BotaniaSoundEvents.ding, SoundCategory.PLAYERS, 1F, 1F);
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
/*public int getMana(ItemStack stack) {
@@ -157,7 +162,7 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
}
public IManaPool getManaPool(ItemStack stack) {
MinecraftServer server = MinecraftServer.getServer();
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if(server == null)
return fallbackPool;
@@ -13,6 +13,8 @@ package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -34,7 +36,7 @@ public class ItemObedienceStick extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemStack stack, 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;
@@ -60,9 +62,11 @@ public class ItemObedienceStick extends ItemMod {
}
if(player.worldObj.isRemote)
player.swingItem();
player.swingArm(hand);
return EnumActionResult.SUCCESS;
}
return false;
return EnumActionResult.PASS;
}
public static abstract class Actuator {
@@ -13,6 +13,9 @@ package vazkii.botania.common.item;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.RayTraceResult;
@@ -27,22 +30,22 @@ public class ItemOpenBucket extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
RayTraceResult RayTraceResult = getRayTraceResultFromPlayer(par2World, par3EntityPlayer, true);
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
RayTraceResult RayTraceResult = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
if(RayTraceResult == null)
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
else {
if(RayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK) {
if(RayTraceResult.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK) {
BlockPos pos = RayTraceResult.getBlockPos();
if(!par2World.isBlockModifiable(par3EntityPlayer, pos))
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
if(!par3EntityPlayer.canPlayerEdit(pos, RayTraceResult.sideHit, par1ItemStack))
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
Material material = par2World.getBlockState(pos).getBlock().getMaterial();
Material material = par2World.getBlockState(pos).getMaterial();
int l = par2World.getBlockState(pos).getBlock().getMetaFromState(par2World.getBlockState(pos)); // hack to get meta so we don't have to know the level prop
if((material == Material.lava || material == Material.water) && l == 0) {
@@ -51,11 +54,11 @@ public class ItemOpenBucket extends ItemMod {
for(int x = 0; x < 5; x++)
par2World.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0, 0, 0);
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
}
@@ -14,6 +14,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -28,7 +31,7 @@ public class ItemOvergrowthSeed extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
IBlockState state = world.getBlockState(pos);
ItemStack blockStack = new ItemStack(state.getBlock());
int[] ids = OreDictionary.getOreIDs(blockStack);
@@ -39,10 +42,10 @@ public class ItemOvergrowthSeed extends ItemMod {
world.setBlockState(pos, ModBlocks.enchantedSoil.getDefaultState());
stack.stackSize--;
return true;
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
}
@@ -14,7 +14,11 @@ import java.util.List;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.text.translation.I18n;
@@ -32,7 +36,7 @@ public class ItemPinkinator extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand 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)
@@ -42,16 +46,16 @@ public class ItemPinkinator extends ItemMod {
EntityPinkWither pink = new EntityPinkWither(world);
pink.setLocationAndAngles(wither.posX, wither.posY, wither.posZ, wither.rotationYaw, wither.rotationPitch);
world.spawnEntityInWorld(pink);
world.playSoundAtEntity(wither, "random.explode", 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
pink.playSound(SoundEvents.entity_generic_explode, 4F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
}
player.addStat(ModAchievements.pinkinator, 1);
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, wither.posX, wither.posY, wither.posZ, 1D, 0D, 0D);
stack.stackSize--;
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return stack;
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
@@ -17,6 +17,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -38,7 +40,7 @@ public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMin
}
@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, BlockPos pos, EnumFacing side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
public EnumActionResult onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, BlockPos pos, EnumHand hand, EnumFacing side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
if(BlockRailBase.isRailBlock(p_77648_3_.getBlockState(pos))) {
if(!p_77648_3_.isRemote) {
EntityMinecart entityminecart = new EntityPoolMinecart(p_77648_3_, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
@@ -50,10 +52,10 @@ public class ItemPoolMinecart extends ItemMod implements ICraftAchievement, IMin
}
--p_77648_1_.stackSize;
return true;
return EnumActionResult.SUCCESS;
}
return false;
return EnumActionResult.PASS;
}
@Override
@@ -11,7 +11,11 @@
package vazkii.botania.common.item;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
@@ -59,18 +63,19 @@ public class ItemSextant extends ItemMod {
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
if(getMaxItemUseDuration(stack) - count < 10)
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
if(getMaxItemUseDuration(stack) - count < 10
|| !(living instanceof EntityPlayer))
return;
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
if(y != -1) {
World world = player.worldObj;
World world = living.worldObj;
Vector3 source = new Vector3(x, y, z);
double radius = calculateRadius(stack, player);
double radius = calculateRadius(stack, ((EntityPlayer) living));
if(count % 10 == 0)
for(int i = 0; i < 360; i++) {
@@ -83,8 +88,10 @@ public class ItemSextant extends ItemMod {
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time) {
double radius = calculateRadius(stack, player);
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase living, int time) {
if(!(living instanceof EntityPlayer)) return;
double radius = calculateRadius(stack, ((EntityPlayer) living));
if(radius > 1) {
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
@@ -95,7 +102,7 @@ public class ItemSextant extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
Botania.proxy.removeSextantMultiblock();
if(!par3EntityPlayer.isSneaking()) {
@@ -108,10 +115,10 @@ public class ItemSextant extends ItemMod {
}
} else ItemNBTHelper.setInt(par1ItemStack, TAG_SOURCE_Y, -1);
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
par3EntityPlayer.setActiveHand(hand);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
public static double calculateRadius(ItemStack stack, EntityPlayer player) {
@@ -136,7 +143,7 @@ public class ItemSextant extends ItemMod {
@SideOnly(Side.CLIENT)
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) {
ItemStack onUse = player.getItemInUse();
ItemStack onUse = player.getActiveItemStack();
int time = player.getItemInUseCount();
if(onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) {
@@ -16,12 +16,18 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
@@ -48,15 +54,15 @@ public class ItemSignalFlare extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(par1ItemStack.getItemDamage() == 0) {
if(par2World.isRemote)
par3EntityPlayer.swingItem();
par3EntityPlayer.swingArm(hand);
else {
EntitySignalFlare flare = new EntitySignalFlare(par2World);
flare.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ);
flare.setColor(getColor(par1ItemStack));
par2World.playSoundAtEntity(par3EntityPlayer, "random.explode", 40F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F);
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, SoundEvents.entity_generic_explode, SoundCategory.PLAYERS, 40F, (1.0F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.2F) * 0.7F);
par2World.spawnEntityInWorld(flare);
@@ -65,7 +71,7 @@ public class ItemSignalFlare extends ItemMod {
List<EntityLivingBase> entities = par2World.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(par3EntityPlayer.posX - range, par3EntityPlayer.posY - range, par3EntityPlayer.posZ - range, par3EntityPlayer.posX + range, par3EntityPlayer.posY + range, par3EntityPlayer.posZ + range));
for(EntityLivingBase entity : entities)
if(entity != par3EntityPlayer && (!(entity instanceof EntityPlayer) || MinecraftServer.getServer() == null || MinecraftServer.getServer().isPVPEnabled())) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 50, 5));
entity.addPotionEffect(new PotionEffect(MobEffects.moveSlowdown, 50, 5));
stunned++;
}
@@ -73,9 +79,10 @@ public class ItemSignalFlare extends ItemMod {
par3EntityPlayer.addStat(ModAchievements.signalFlareStun, 1);
}
par1ItemStack.damageItem(200, par3EntityPlayer);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
@Override
@@ -10,9 +10,13 @@
*/
package vazkii.botania.common.item;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import vazkii.botania.common.entity.EntityVineBall;
import vazkii.botania.common.lib.LibItemNames;
@@ -25,21 +29,21 @@ public class ItemSlingshot extends ItemMod {
}
@Override
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityLivingBase living, int par4) {
int j = getMaxItemUseDuration(par1ItemStack) - par4;
if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) {
if(!(living instanceof EntityPlayer) || ((EntityPlayer) living).capabilities.isCreativeMode || ((EntityPlayer) living).inventory.hasItem(ModItems.vineBall)) {
float f = j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;
if(f < 1F)
return;
if(!par3EntityPlayer.capabilities.isCreativeMode)
par3EntityPlayer.inventory.consumeInventoryItem(ModItems.vineBall);
if(living instanceof EntityPlayer && !((EntityPlayer) living).capabilities.isCreativeMode)
((EntityPlayer) living).inventory.consumeInventoryItem(ModItems.vineBall);
if(!par2World.isRemote) {
EntityVineBall ball = new EntityVineBall(par3EntityPlayer, false);
EntityVineBall ball = new EntityVineBall(living, false);
ball.motionX *= 1.6;
ball.motionY *= 1.6;
ball.motionZ *= 1.6;
@@ -49,7 +53,7 @@ public class ItemSlingshot extends ItemMod {
}
@Override
public ItemStack onItemUseFinish(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ItemStack onItemUseFinish(ItemStack par1ItemStack, World par2World, EntityLivingBase living) {
return par1ItemStack;
}
@@ -64,11 +68,13 @@ public class ItemSlingshot extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall))
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.vineBall)) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
}
@@ -15,6 +15,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -33,7 +35,7 @@ public class ItemSpark extends ItemMod implements ICraftAchievement, IManaGiving
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xv, float yv, float zv) {
public EnumActionResult onItemUse(ItemStack stack, 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;
@@ -46,10 +48,10 @@ public class ItemSpark extends ItemMod implements ICraftAchievement, IManaGiving
attach.attachSpark(spark);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, pos);
}
return true;
return EnumActionResult.SUCCESS;
}
}
return false;
return EnumActionResult.PASS;
}
@Override
@@ -18,6 +18,9 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.translation.I18n;
@@ -86,7 +89,7 @@ public class ItemSpawnerMover extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) {
public EnumActionResult onItemUse(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
if(getEntityId(itemstack) == null) {
if(world.getBlockState(pos).getBlock().equals(Blocks.mob_spawner)) {
TileEntity te = world.getTileEntity(pos);
@@ -103,10 +106,10 @@ public class ItemSpawnerMover extends ItemMod {
float blue = (float) Math.random();
Botania.proxy.wispFX(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F);
}
return true;
} else return false;
return EnumActionResult.SUCCESS;
} else return EnumActionResult.PASS;
} else {
return getDelay(itemstack) <= 0 && placeBlock(itemstack, player, world, pos, side, xOffset, yOffset, zOffset);
return getDelay(itemstack) <= 0 && placeBlock(itemstack, player, world, pos, side, xOffset, yOffset, zOffset) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
}
}
@@ -128,7 +131,7 @@ public class ItemSpawnerMover extends ItemMod {
IBlockState iblockstate1 = Blocks.mob_spawner.onBlockPlaced(world, pos, side, xOffset, yOffset, zOffset, meta, player);
if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) {
world.playSoundEffect((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F), Blocks.mob_spawner.stepSound.getPlaceSound(), (Blocks.mob_spawner.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.mob_spawner.stepSound.getFrequency() * 0.8F);
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;
player.renderBrokenItemStack(itemstack);
player.addStat(ModAchievements.spawnerMoverUse, 1);
@@ -13,8 +13,13 @@ package vazkii.botania.common.item;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.world.World;
import vazkii.botania.common.lib.LibItemNames;
@@ -30,12 +35,11 @@ public class ItemTemperanceStone extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
int dmg = par1ItemStack.getItemDamage();
par1ItemStack.setItemDamage(~dmg & 1);
par2World.playSoundAtEntity(par3EntityPlayer, "random.orb", 0.3F, 0.1F);
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand 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);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Override
@@ -13,10 +13,15 @@ import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import vazkii.botania.common.achievement.ICraftAchievement;
import vazkii.botania.common.achievement.ModAchievements;
@@ -43,21 +48,21 @@ public class ItemThornChakram extends ItemMod implements ICraftAchievement {
}
@Override
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
--p_77659_1_.stackSize;
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
--stack.stackSize;
p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
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));
if(!p_77659_2_.isRemote) {
ItemStack stack = p_77659_1_.copy();
if(!world.isRemote) {
ItemStack copy = stack.copy();
stack.stackSize = 1;
EntityThornChakram c = new EntityThornChakram(p_77659_2_, p_77659_3_, stack);
c.setFire(p_77659_1_.getItemDamage() != 0);
p_77659_2_.spawnEntityInWorld(c);
EntityThornChakram c = new EntityThornChakram(world, player, copy);
c.setFire(stack.getItemDamage() != 0);
world.spawnEntityInWorld(c);
}
return p_77659_1_;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Override
@@ -2,16 +2,21 @@
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
*
* File Created @ [Jun 26, 2014, 7:50:37 PM (GMT)]
*/
package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import vazkii.botania.common.entity.EntityVineBall;
import vazkii.botania.common.lib.LibItemNames;
@@ -23,16 +28,16 @@ public class ItemVineBall extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(!par3EntityPlayer.capabilities.isCreativeMode)
--par1ItemStack.stackSize;
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (par2World.rand.nextFloat() * 0.4F + 0.8F));
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, SoundEvents.entity_arrow_shoot, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if(!par2World.isRemote)
par2World.spawnEntityInWorld(new EntityVineBall(par3EntityPlayer, true));
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
}
@@ -15,15 +15,18 @@ import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
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.BaseAttributeMap;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumHand;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.common.lib.LibItemNames;
@@ -44,19 +47,19 @@ public class ItemVirus extends ItemMod {
}
@Override
public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) {
public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase, EnumHand hand) {
if(par3EntityLivingBase instanceof EntityHorse) {
EntityHorse horse = (EntityHorse) par3EntityLivingBase;
if(horse.getHorseType() != 3 && horse.getHorseType() != 4 && horse.isTame()) {
horse.setHorseType(3 + par1ItemStack.getItemDamage());
BaseAttributeMap attributes = horse.getAttributeMap();
IAttributeInstance movementSpeed = attributes.getAttributeInstance(SharedMonsterAttributes.movementSpeed);
IAttributeInstance health = attributes.getAttributeInstance(SharedMonsterAttributes.maxHealth);
if(horse.getType() != HorseArmorType.ZOMBIE && horse.getType() != HorseArmorType.SKELETON && horse.isTame()) {
horse.setType(par1ItemStack.getItemDamage() == 0 ? HorseArmorType.ZOMBIE : HorseArmorType.SKELETON);
AbstractAttributeMap attributes = horse.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.<IAttribute, EntityHorse>getPrivateValue(EntityHorse.class, null, LibObfuscation.HORSE_JUMP_STRENGTH));
jumpHeight.applyModifier(new AttributeModifier("Ermergerd Virus D:", jumpHeight.getBaseValue() * 0.5, 0));
par2EntityPlayer.worldObj.playSound(par3EntityLivingBase.posX + 0.5D, par3EntityLivingBase.posY + 0.5D, par3EntityLivingBase.posZ + 0.5D, "mob.zombie.remedy", 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F, false);
par3EntityLivingBase.playSound(SoundEvents.entity_zombie_villager_cure, 1.0F + par3EntityLivingBase.worldObj.rand.nextFloat(), par3EntityLivingBase.worldObj.rand.nextFloat() * 0.7F + 1.3F);
par1ItemStack.stackSize--;
return true;
@@ -68,12 +71,12 @@ public class ItemVirus extends ItemMod {
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
EntityLivingBase entity = event.entityLiving;
if(entity.ridingEntity != null && entity.ridingEntity instanceof EntityLivingBase)
entity = (EntityLivingBase) entity.ridingEntity;
if(entity.isRiding() && entity.getRidingEntity() instanceof EntityLivingBase)
entity = (EntityLivingBase) entity.getRidingEntity();
if(entity instanceof EntityHorse && event.source == DamageSource.fall) {
EntityHorse horse = (EntityHorse) entity;
if((horse.getHorseType() == 3 || horse.getHorseType() == 4) && horse.isTame())
if((horse.getType() == HorseArmorType.ZOMBIE || horse.getType() == HorseArmorType.SKELETON) && horse.isTame())
event.setCanceled(true);
}
}
@@ -11,7 +11,12 @@
package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
@@ -25,7 +30,7 @@ public class ItemWorldSeed extends ItemMod {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand 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) {
@@ -33,17 +38,18 @@ public class ItemWorldSeed extends ItemMod {
player.rotationYaw = 0F;
player.setPositionAndUpdate(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5);
while(!world.getCollidingBoundingBoxes(player, player.getEntityBoundingBox()).isEmpty())
while(!world.getCubes(player, player.getEntityBoundingBox()).isEmpty())
player.setPositionAndUpdate(player.posX, player.posY + 1, player.posZ);
world.playSoundAtEntity(player, "mob.endermen.portal", 1F, 1F);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.entity_endermen_teleport, SoundCategory.PLAYERS, 1F, 1F);
for(int i = 0; i < 50; i++)
Botania.proxy.sparkleFX(world, 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--;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return stack;
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
@@ -55,7 +55,7 @@ public class ItemBlockSpecialFlower extends ItemBlockMod implements IRecipeKeyPr
tile.onBlockAdded(world, pos, newState);
tile.onBlockPlacedBy(world, pos, newState, player, stack);
if(!world.isRemote)
world.markBlockForUpdate(pos);
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.item.equipment.tool.manasteel;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -62,8 +63,8 @@ public class ItemManasteelSword extends ItemSword implements IManaUsingItem {
}
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, BlockPos pos, EntityLivingBase entity) {
if(usesMana(stack) && block.getBlockHardness(world, pos) != 0F)
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entity) {
if(usesMana(stack) && state.getBlockHardness(world, pos) != 0F)
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
return true;
@@ -41,7 +41,7 @@ public class LensFire extends Lens {
TileIncensePlate plate = (TileIncensePlate) entity.worldObj.getTileEntity(pos.getBlockPos());
plate.ignite();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate);
} else if(blockAt_.isAir(entity.worldObj, pos_))
} else if(blockAt_.isAir(entity.worldObj.getBlockState(pos_), entity.worldObj, pos_))
entity.worldObj.setBlockState(pos_, Blocks.fire.getDefaultState());
}
@@ -34,7 +34,7 @@ public class LensLight extends Lens {
if(blockAt == ModBlocks.manaFlame)
entity.worldObj.setBlockState(pos.getBlockPos(), Blocks.air.getDefaultState());
else if(blockAt_.isAir(entity.worldObj, pos_) || blockAt_.isReplaceable(entity.worldObj, pos_)) {
else if(blockAt_.isAir(entity.worldObj.getBlockState(pos_), entity.worldObj, pos_) || blockAt_.isReplaceable(entity.worldObj, pos_)) {
entity.worldObj.setBlockState(pos_, ModBlocks.manaFlame.getDefaultState());
TileEntity tile = entity.worldObj.getTileEntity(pos_);
@@ -52,7 +52,7 @@ public class LensMine extends Lens {
TileEntity tile = world.getTileEntity(pos_);
IBlockState state = world.getBlockState(pos_);
float hardness = block.getBlockHardness(world, pos_);
float hardness = state.getBlockHardness(world, pos_);
int neededHarvestLevel = block.getHarvestLevel(state);
int mana = burst.getMana();
@@ -10,6 +10,7 @@
*/
package vazkii.botania.common.item.lens;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
@@ -31,7 +32,7 @@ public class LensPiston extends Lens {
IBlockState state = entity.worldObj.getBlockState(pos.getBlockPos());
TileEntity tile = entity.worldObj.getTileEntity(pos.getBlockPos());
if(state.getBlock().getMobilityFlag() == 0 && state.getBlock() != Blocks.obsidian && state.getBlock().getBlockHardness(entity.worldObj, pos_) >= 0 && tile == null) {
if(state.getMobilityFlag() == EnumPushReaction.NORMAL && state.getBlock() != Blocks.obsidian && state.getBlockHardness(entity.worldObj, pos_) >= 0 && tile == null) {
entity.worldObj.destroyBlock(pos.getBlockPos(), false);
entity.worldObj.setBlockState(pos_, state, 1 | 2);
}
@@ -34,7 +34,7 @@ public class LensRedirect extends Lens {
Vector3 tileVec = Vector3.fromTileEntityCenter(tile);
Vector3 sourceVec = new Vector3(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5);
AxisAlignedBB axis = entity.worldObj.getBlockState(coords).getBlock().getCollisionBoundingBox(entity.worldObj, coords, entity.worldObj.getBlockState(coords));
AxisAlignedBB axis = entity.worldObj.getBlockState(coords).getCollisionBoundingBox(entity.worldObj, coords);
if(axis == null)
axis = new AxisAlignedBB(coords, coords.add(1, 1, 1));
@@ -31,7 +31,7 @@ public class LensWeight extends Lens {
IBlockState state = entity.worldObj.getBlockState(pos.getBlockPos());
int neededHarvestLevel = block.getHarvestLevel(state);
if(blockBelow.isAir(entity.worldObj, pos.getBlockPos().down()) && block.getBlockHardness(entity.worldObj, pos.getBlockPos()) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(pos.getBlockPos()) == null && block.canSilkHarvest(entity.worldObj, pos.getBlockPos(), entity.worldObj.getBlockState(pos.getBlockPos()), null)) {
if(blockBelow.isAir(entity.worldObj.getBlockState(pos.getBlockPos().down()), entity.worldObj, pos.getBlockPos().down()) && state.getBlockHardness(entity.worldObj, pos.getBlockPos()) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(pos.getBlockPos()) == null && block.canSilkHarvest(entity.worldObj, pos.getBlockPos(), entity.worldObj.getBlockState(pos.getBlockPos()), null)) {
EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, pos.getBlockPos().getX() + 0.5, pos.getBlockPos().getY() + 0.5, pos.getBlockPos().getZ() + 0.5, state);
entity.worldObj.spawnEntityInWorld(falling);
}
@@ -13,6 +13,8 @@ package vazkii.botania.common.item.material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -29,17 +31,16 @@ public class ItemPetal extends Item16Colors implements IFlowerComponent {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
ItemStack stackToPlace = new ItemStack(ModBlocks.buriedPetals, 1, par1ItemStack.getItemDamage());
stackToPlace.onItemUse(par2EntityPlayer, par3World, pos, side, par8, par9, par10);
stackToPlace.onItemUse(par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10);
if(stackToPlace.stackSize == 0) {
if(!par2EntityPlayer.capabilities.isCreativeMode)
par1ItemStack.stackSize--;
return true;
}
return false;
return EnumActionResult.SUCCESS;
}
@Override
@@ -14,6 +14,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.BotaniaCreativeTab;
import net.minecraftforge.fml.common.registry.GameRegistry;
@@ -22,8 +24,8 @@ public class ItemModRecord extends ItemRecord {
private final String file;
public ItemModRecord(String record, String name) {
super("botania:" + record);
public ItemModRecord(String record, SoundEvent sound, String name) {
super("botania:" + record, sound);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setUnlocalizedName(name);
file = "botania:music." + record;
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.record;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.lib.LibItemNames;
public class ItemRecordGaia1 extends ItemModRecord {
public ItemRecordGaia1() {
super("gaia1", LibItemNames.RECORD_GAIA1);
super("gaia1", BotaniaSoundEvents.gaiaMusic1, LibItemNames.RECORD_GAIA1);
}
}
@@ -10,12 +10,13 @@
*/
package vazkii.botania.common.item.record;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.lib.LibItemNames;
public class ItemRecordGaia2 extends ItemModRecord {
public ItemRecordGaia2() {
super("gaia2", LibItemNames.RECORD_GAIA2);
super("gaia2", BotaniaSoundEvents.gaiaMusic2, LibItemNames.RECORD_GAIA2);
}
}
@@ -14,6 +14,8 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -33,8 +35,8 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, pos, side, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F);
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F);
}
@Override
@@ -17,6 +17,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
@@ -45,27 +47,30 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, ICraftAchiev
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
return place(par1ItemStack, par2EntityPlayer, par3World, pos, side, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F);
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
return place(par1ItemStack, par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F);
}
public static boolean place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) {
public static EnumActionResult place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, 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, par2EntityPlayer, cost, false)) {
int entities = par3World.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(par2EntityPlayer, par3World, pos, side, par8, par9, par10);
stackToPlace.onItemUse(par2EntityPlayer, par3World, pos, hand, side, par8, par9, par10);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(par3World, 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;
}
}
return EnumActionResult.FAIL;
}
return true;
return EnumActionResult.PASS;
}
@Override
@@ -17,6 +17,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -26,6 +30,7 @@ import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.item.ItemMod;
@@ -43,17 +48,18 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer p, EnumHand hand) {
if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) {
if(world.isRemote) {
int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15;
long seedxor = world.rand.nextLong();
doHighlight(world, new BlockPos(p), range, seedxor);
p.swingItem();
} else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F);
p.swingArm(hand);
} else world.playSound(null, p.posX, p.posY, p.posZ, BotaniaSoundEvents.divinationRod, SoundCategory.PLAYERS, 1F, 1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return stack;
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
public void doHighlight(World world, BlockPos pos, int range, long seedxor) {
@@ -20,10 +20,13 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.EnumFacing;
@@ -69,7 +72,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
IBlockState wstate = par3World.getBlockState(pos);
if(par2EntityPlayer.isSneaking()) {
@@ -79,10 +82,10 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
Item item = Item.getItemFromBlock(wstate.getBlock());
boolean set = setBlock(par1ItemStack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
par2EntityPlayer.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, par1ItemStack);
displayRemainderCounter(par2EntityPlayer, par1ItemStack);
return set;
return EnumActionResult.SUCCESS;
}
}
} else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) {
@@ -96,17 +99,17 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, pos.getZ());
setTargetBlock(par1ItemStack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
if(par3World.isRemote)
par2EntityPlayer.swingItem();
par2EntityPlayer.swingArm(hand);
}
}
return false;
return EnumActionResult.SUCCESS;
}
@SubscribeEvent
public void onLeftClick(PlayerInteractEvent event) {
if(event.action == Action.LEFT_CLICK_BLOCK) {
ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
ItemStack stack = event.entityPlayer.getHeldItemMainhand();
if(stack != null && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) {
if(exchange(event.world, event.entityPlayer, event.pos, stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack))))
ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true);
@@ -189,15 +192,15 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
// Check to see if the block is visible on any side:
for(EnumFacing dir : EnumFacing.VALUES) {
BlockPos adjPos = pos_.offset(dir);
Block adjBlock = world.getBlockState(adjPos).getBlock();
IBlockState adjState = world.getBlockState(adjPos);
// If the side of the adjacent block facing this block is
// _not_ solid, then this block is considered "visible"
// and should be replaced.
// If there is a rendering-specific way to check for this,
// that should be placed in preference to this.
if(!adjBlock.isSideSolid(world, adjPos, dir.getOpposite())) {
if(!adjState.isSideSolid(world, adjPos, dir.getOpposite())) {
coordsList.add(pos_);
break;
}
@@ -216,7 +219,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(placeStack != null) {
IBlockState stateAt = world.getBlockState(pos);
Block blockAt = stateAt.getBlock();
if(!blockAt.isAir(world, pos) && blockAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
if(!blockAt.isAir(world.getBlockState(pos), world, pos) && stateAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
if(!world.isRemote) {
if(!player.capabilities.isCreativeMode) {
List<ItemStack> drops = blockAt.getDrops(world, pos, stateAt, 0);
@@ -387,7 +390,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
@Override
@SideOnly(Side.CLIENT)
public List<BlockPos> getWireframesToDraw(EntityPlayer player, ItemStack stack) {
ItemStack holding = player.getCurrentEquippedItem();
ItemStack holding = player.getHeldItemMainhand();
if(holding != stack || !canExchange(stack))
return null;
@@ -12,8 +12,12 @@ package vazkii.botania.common.item.rod;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
@@ -42,7 +46,7 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(!par3World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) {
EntityFlameRing entity = new EntityFlameRing(player.worldObj);
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
@@ -50,10 +54,10 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
par1ItemStack.setItemDamage(COOLDOWN);
ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, true);
par3World.playSoundAtEntity(player, "mob.blaze.breathe", 1F, 1F);
par3World.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.entity_blaze_ambient, SoundCategory.PLAYERS, 1F, 1F);
}
return true;
return EnumActionResult.SUCCESS;
}
@Override
@@ -17,9 +17,13 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
@@ -77,14 +81,14 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown);
EntityPlayer player = (EntityPlayer) par3Entity;
PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
PotionEffect haste = player.getActivePotionEffect(MobEffects.digSpeed);
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
if(player.getCurrentEquippedItem() == stack && player.swingProgress == check && !world.isRemote)
if(player.getHeldItemMainhand() == stack && player.swingProgress == check && !world.isRemote)
leftClick(player);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand 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);
@@ -134,7 +138,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
if(item != null) {
if(BotaniaAPI.isEntityBlacklistedFromGravityRod(item.getClass()))
return stack;
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if(ManaItemHandler.requestManaExactForTool(stack, player, COST, true)) {
if(item instanceof EntityItem)
@@ -143,8 +147,8 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
if(item instanceof EntityLivingBase) {
EntityLivingBase targetEntity = (EntityLivingBase)item;
targetEntity.fallDistance = 0.0F;
if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null)
targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true, true));
if(targetEntity.getActivePotionEffect(MobEffects.moveSlowdown) == null)
targetEntity.addPotionEffect(new PotionEffect(MobEffects.moveSlowdown, 2, 3, true, true));
}
Vector3 target3 = Vector3.fromEntityCenter(player);
@@ -169,12 +173,12 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
ItemNBTHelper.setInt(stack, TAG_TARGET, item.getEntityId());
ItemNBTHelper.setDouble(stack, TAG_DIST, length);
}
}
if(item != null)
ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, 5);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
return stack;
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) {
@@ -195,7 +199,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
}
public static void leftClick(EntityPlayer player) {
ItemStack stack = player.getHeldItem();
ItemStack stack = player.getHeldItemMainhand();
if(stack != null && stack.getItem() == ModItems.gravityRod) {
int targetID = ItemNBTHelper.getInt(stack, TAG_TARGET, -1);
ItemNBTHelper.getDouble(stack, TAG_DIST, -1);
@@ -15,6 +15,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.item.IAvatarTile;
@@ -22,6 +25,7 @@ import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.entity.EntityMagicMissile;
@@ -52,7 +56,10 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
if(!(living instanceof EntityPlayer)) return;
EntityPlayer player = ((EntityPlayer) living);
if(count != getMaxItemUseDuration(stack) && count % (IManaProficiencyArmor.Helper.hasProficiency(player) ? 1 : 2) == 0 && !player.worldObj.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, false)) {
if(spawnMissile(player.worldObj, player, player.posX + (Math.random() - 0.5 * 0.1), player.posY + 2.4 + (Math.random() - 0.5 * 0.1), player.posZ + (Math.random() - 0.5 * 0.1)))
ManaItemHandler.requestManaExactForTool(stack, player, COST_PER, true);
@@ -70,7 +77,7 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
missile.setPosition(x, y, z);
if(missile.getTarget()) {
if(!world.isRemote) {
world.playSoundEffect(x, y, z, "botania:missile", 0.6F, 0.8F + (float) Math.random() * 0.2F);
missile.playSound(BotaniaSoundEvents.missile, 0.6F, 0.8F + (float) Math.random() * 0.2F);
world.spawnEntityInWorld(missile);
}
@@ -80,9 +87,9 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
@@ -18,12 +18,17 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import vazkii.botania.api.item.IAvatarTile;
import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
@@ -48,7 +53,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
if(!par2World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false)) {
Block place = ModBlocks.bifrost;
Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize();
@@ -67,14 +72,14 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
int time = prof ? (int) (TIME * 1.6) : TIME;
BlockPos playerPos = new BlockPos((int) x, (int) y, (int) z);
while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlockState(playerPos).getBlock().isAir(par2World, playerPos) || par2World.getBlockState(playerPos).getBlock() == place) {
while(count < maxlen && (int) lx == (int) x && (int) ly == (int) y && (int) lz == (int) z || count < 4 || par2World.getBlockState(playerPos).getBlock().isAir(par2World.getBlockState(playerPos), par2World, playerPos) || par2World.getBlockState(playerPos).getBlock() == place) {
if(y >= 256 || y <= 0)
break;
for(int i = -2; i < 1; i++)
for(int j = -2; j < 1; j++) {
BlockPos pos_ = new BlockPos((int) x + i, (int) y, (int) z + j);
if(par2World.getBlockState(pos_).getBlock().isAir(par2World, pos_) || par2World.getBlockState(pos_).getBlock() == place) {
if(par2World.getBlockState(pos_).getBlock().isAir(par2World.getBlockState(pos_), par2World, pos_) || par2World.getBlockState(pos_).getBlock() == place) {
par2World.setBlockState(pos_, place.getDefaultState());
TileBifrost tile = (TileBifrost) par2World.getTileEntity(pos_);
if(tile != null) {
@@ -97,13 +102,13 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
}
if(count > 0) {
par2World.playSoundAtEntity(par3EntityPlayer, "botania:bifrostRod", 0.5F, 0.25F);
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, BotaniaSoundEvents.bifrostRod, SoundCategory.PLAYERS, 0.5F, 0.25F);
ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, MANA_COST, false);
par1ItemStack.setItemDamage(TIME);
}
}
return par1ItemStack;
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
@@ -177,7 +182,7 @@ public class ItemRainbowRod extends ItemMod implements IManaUsingItem, IAvatarWi
continue;
BlockPos pos = new BlockPos(ex, py, ez);
Block block = world.getBlockState(pos).getBlock();
if(block.isAir(world, pos)) {
if(block.isAir(world.getBlockState(pos), world, pos)) {
world.setBlockState(pos, ModBlocks.bifrost.getDefaultState());
TileBifrost tileBifrost = (TileBifrost) world.getTileEntity(pos);
tileBifrost.ticks = 10;
@@ -14,6 +14,9 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
@@ -31,7 +34,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(!world.isRemote && ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, false)) {
Vector3 playerVec = Vector3.fromEntityCenter(player);
Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3);
@@ -45,7 +48,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
if(entities == 0) {
ItemStack stackToPlace = new ItemStack(Blocks.dirt);
stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), EnumFacing.DOWN, 0F, 0F, 0F);
stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), hand, EnumFacing.DOWN, 0F, 0F, 0F);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
@@ -55,9 +58,9 @@ public class ItemSkyDirtRod extends ItemDirtRod {
}
}
if(world.isRemote)
player.swingItem();
player.swingArm(hand);
return stack;
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
@@ -15,11 +15,17 @@ import java.util.WeakHashMap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.item.IManaProficiencyArmor;
@@ -54,13 +60,16 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer p, int time) {
public void onUsingTick(ItemStack stack, EntityLivingBase living, int time) {
if(!(living instanceof EntityPlayer)) return;
EntityPlayer p = ((EntityPlayer) living);
if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false))
return;
@@ -84,8 +93,8 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
if(data.progress <= 0) {
if(!p.worldObj.isRemote) {
p.worldObj.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 1 | 2);
p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F);
p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F);
p.worldObj.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.item_flintandsteel_use, SoundCategory.PLAYERS, 0.6F, 1F);
p.worldObj.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.block_fire_ambient, SoundCategory.PLAYERS, 1F, 1F);
ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, true);
playerData.remove(p);
@@ -113,7 +122,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
Botania.proxy.wispFX(p.worldObj, x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F);
}
if(time % 10 == 0)
p.worldObj.playSoundAtEntity(p, "fire.fire", (float) Math.random() / 2F + 0.5F, 1F);
p.worldObj.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.block_fire_ambient, SoundCategory.PLAYERS, (float) Math.random() / 2F + 0.5F, 1F);
}
}
}
@@ -18,13 +18,19 @@ import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@@ -87,15 +93,15 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
if(count != getMaxItemUseDuration(stack) && count % 10 == 0)
terraform(stack, player.worldObj, player);
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count) {
if(count != getMaxItemUseDuration(stack) && count % 10 == 0 && living instanceof EntityPlayer)
terraform(stack, living.worldObj, ((EntityPlayer) living));
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
par3EntityPlayer.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
public void terraform(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
@@ -133,7 +139,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
for(EnumFacing dir : LibMisc.CARDINAL_DIRECTIONS) {
BlockPos pos_ = pos.offset(dir);
Block block_ = par2World.getBlockState(pos_).getBlock();
if(block_.isAir(par2World, pos_) || block_.isReplaceable(par2World, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) {
if(block_.isAir(par2World.getBlockState(pos_), par2World, pos_) || block_.isReplaceable(par2World, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) {
airBlocks.add(pos_);
hasAir = true;
}
@@ -162,7 +168,7 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
if(!blocks.isEmpty()) {
for(int i = 0; i < 10; i++)
par2World.playSoundAtEntity(par3EntityPlayer, "step.sand", 1F, 0.4F);
par2World.playSound(null, par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, SoundEvents.block_sand_step, SoundCategory.BLOCKS, 1F, 0.4F);
for(int i = 0; i < 120; i++)
Botania.proxy.sparkleFX(par2World, xCenter - range + range * 2 * Math.random(), yCenter + 2 + (Math.random() - 0.5) * 2, zCenter - range + range * 2 * Math.random(), 0.35F, 0.2F, 0.05F, 2F, 5);
}
@@ -18,6 +18,10 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -26,6 +30,7 @@ import vazkii.botania.api.item.IAvatarWieldable;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.brew.ModPotions;
@@ -54,7 +59,6 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean holding) {
if(par3Entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) par3Entity;
player.getCurrentEquippedItem();
boolean damaged = par1ItemStack.getItemDamage() > 0;
if(damaged && !isFlying(par1ItemStack))
@@ -63,13 +67,13 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
int max = FALL_MULTIPLIER * FLY_TIME;
if(par1ItemStack.getItemDamage() >= max) {
setFlying(par1ItemStack, false);
player.stopUsingItem();
player.resetActiveHand();
} else if(isFlying(par1ItemStack)) {
if(holding) {
player.fallDistance = 0F;
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player) ? 1.6 : 1.25;
player.worldObj.playSoundAtEntity(player, "botania:airRod", 0.1F, 0.25F);
player.worldObj.playSound(null, player.posX, player.posY, player.posZ, BotaniaSoundEvents.airRod, SoundCategory.PLAYERS, 0.1F, 0.25F);
for(int i = 0; i < 5; i++)
Botania.proxy.wispFX(player.worldObj, player.posX, player.posY, player.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5));
}
@@ -85,22 +89,18 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand hand) {
int meta = par1ItemStack.getItemDamage();
if(meta != 0 || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, false)) {
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
par3EntityPlayer.setActiveHand(hand);
if(meta == 0) {
setFlying(par1ItemStack, true);
ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, COST, true);
setFlying(par1ItemStack, true);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
}
return par1ItemStack;
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
}
@Override
@@ -148,8 +148,8 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
Botania.proxy.wispFX(p.worldObj, p.posX, p.posY + i, p.posZ, 0.25F, 0.25F, 0.25F, 0.35F + (float) Math.random() * 0.1F, 0.2F * (float) (Math.random() - 0.5), -0.01F * (float) Math.random(), 0.2F * (float) (Math.random() - 0.5));
if(!world.isRemote) {
p.worldObj.playSoundAtEntity(p, "botania:dash", 1F, 1F);
p.addPotionEffect(new PotionEffect(ModPotions.featherfeet.id, 100, 0));
p.worldObj.playSound(null, p.posX, p.posY, p.posZ, BotaniaSoundEvents.dash, SoundCategory.PLAYERS, 1F, 1F);
p.addPotionEffect(new PotionEffect(ModPotions.featherfeet, 100, 0));
tile.recieveMana(-COST);
}
}
@@ -4,6 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.RayTraceResult;
@@ -25,28 +27,30 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
public EnumActionResult onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.doesWaterVaporize()) {
// Adapted from bucket code
RayTraceResult mop = getRayTraceResultFromPlayer(par3World, par2EntityPlayer, false);
RayTraceResult mop = getMovingObjectPositionFromPlayer(par3World, par2EntityPlayer, false);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos hitPos = mop.getBlockPos();
if(!par3World.isBlockModifiable(par2EntityPlayer, hitPos))
return false;
return EnumActionResult.FAIL;
BlockPos placePos = hitPos.offset(mop.sideHit);
if(par2EntityPlayer.canPlayerEdit(placePos, mop.sideHit, par1ItemStack)) {
if (ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true)
&& ((ItemBucket) Items.water_bucket).tryPlaceContainedLiquid(par3World, placePos)) {
&& ((ItemBucket) Items.water_bucket).tryPlaceContainedLiquid(par2EntityPlayer, par3World, placePos)) {
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(par3World, 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);
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.FAIL;
}
return true;
return EnumActionResult.PASS;
}
@Override