diff --git a/common/MysticWorld/Items/ItemStaffEarth.java b/common/MysticWorld/Items/ItemStaffEarth.java index e220228..0a7d0dd 100644 --- a/common/MysticWorld/Items/ItemStaffEarth.java +++ b/common/MysticWorld/Items/ItemStaffEarth.java @@ -16,9 +16,12 @@ import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; @@ -41,27 +44,49 @@ public class ItemStaffEarth extends Item { itemIcon = iconRegister.registerIcon("MysticTextures:StaffEarth"); } - public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ - if (!entityPlayer.canPlayerEdit(par4, par5, par6, par7, itemStack)) + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) + { + if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return false; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, true); + + if (movingobjectposition == null) + { + return itemStack; + } + else + { + if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!world.canMineBlock(entityPlayer, i, j, k)) + { + return itemStack; + } + + if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack)) + { + return itemStack; + } + else + { + if (applyBonemeal(itemStack, world, i, j, k, entityPlayer)) + { + if (!world.isRemote) + { + world.playAuxSFX(2005, i, j, k, 0); + } + return itemStack; + } + } + } + } } else { - if (applyBonemeal(itemStack, world, par4, par5, par6, entityPlayer)) - { - if (!world.isRemote) - { - world.playAuxSFX(2005, par4, par5, par6, 0); - } - return true; - } - return false; - } - } - - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) - { world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0); if (!world.isRemote) @@ -72,6 +97,9 @@ public class ItemStaffEarth extends Item { } return itemStack; + } + + return itemStack; } public static boolean applyBonemeal(ItemStack itemStack, World par1World, int par2, int par3, int par4, EntityPlayer player) @@ -99,7 +127,6 @@ public class ItemStaffEarth extends Item { { ((BlockSapling)Block.sapling).markOrGrowMarked(par1World, par2, par3, par4, par1World.rand); } - itemStack.damageItem(1, player); } return true; @@ -113,6 +140,16 @@ public class ItemStaffEarth extends Item { itemStack.damageItem(1, player); } + else if (l == Block.deadBush.blockID) + { + if (!par1World.isRemote) + { + par1World.setBlock(par2, par3, par4, 0); + par1World.spawnEntityInWorld(new EntityItem(par1World, par2, par3, par4, new ItemStack(Block.sapling, 1))); + } + + itemStack.damageItem(1, player); + } else if (l != Block.mushroomBrown.blockID && l != Block.mushroomRed.blockID) { if (l != Block.melonStem.blockID && l != Block.pumpkinStem.blockID) diff --git a/common/MysticWorld/Items/ItemStaffEnegy.java b/common/MysticWorld/Items/ItemStaffEnegy.java index 004601e..4b7c74d 100644 --- a/common/MysticWorld/Items/ItemStaffEnegy.java +++ b/common/MysticWorld/Items/ItemStaffEnegy.java @@ -6,11 +6,14 @@ import MysticWorld.MysticWorld; import MysticWorld.Blocks.BlockHandler; import MysticWorld.Entity.EntityChargeEnergy; import MysticWorld.Entity.EntityChargeFire; +import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class ItemStaffEnegy extends Item{ @@ -28,67 +31,99 @@ public class ItemStaffEnegy extends Item{ itemIcon = iconRegister.registerIcon("MysticTextures:StaffEnergy"); } - public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ - if (par7 == 0) - { - --par5; - } - - if (par7 == 1) - { - ++par5; - } - - if (par7 == 2) - { - --par6; - } - - if (par7 == 3) - { - ++par6; - } - - if (par7 == 4) - { - --par4; - } - - if (par7 == 5) - { - ++par4; - } - - if (!entityPlayer.canPlayerEdit(par4, par5, par6, par7, itemStack)) - { - return false; - } - else - { - int i1 = world.getBlockId(par4, par5, par6); - - if (i1 == 0) - { - world.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); - world.setBlock(par4, par5, par6, BlockHandler.lightCube.blockID); - } - - itemStack.damageItem(1, entityPlayer); - return true; - } - } - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { - world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0); - - if (!world.isRemote) + if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - world.spawnEntityInWorld(new EntityChargeEnergy(world, entityPlayer)); - - itemStack.damageItem(1, entityPlayer); + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, true); + + if (movingobjectposition == null) + { + return itemStack; + } + else + { + if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!world.canMineBlock(entityPlayer, i, j, k)) + { + return itemStack; + } + + if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack)) + { + return itemStack; + } + + else + { + if (movingobjectposition.sideHit == 0) + { + --j; + } + + if (movingobjectposition.sideHit == 1) + { + ++j; + } + + if (movingobjectposition.sideHit == 2) + { + --k; + } + + if (movingobjectposition.sideHit == 3) + { + ++k; + } + + if (movingobjectposition.sideHit == 4) + { + --i; + } + + if (movingobjectposition.sideHit == 5) + { + ++i; + } + + + if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack)) + { + return itemStack; + } + else + { + if (world.isAirBlock(i, j, k)) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, BlockHandler.lightCube.blockID); + } + + itemStack.damageItem(1, entityPlayer); + return itemStack; + } + } + } + } + } + else + { + world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0); + + if (!world.isRemote) + { + world.spawnEntityInWorld(new EntityChargeEnergy(world, entityPlayer)); + + itemStack.damageItem(1, entityPlayer); + } + + return itemStack; } - return itemStack; } diff --git a/common/MysticWorld/Items/ItemStaffFire.java b/common/MysticWorld/Items/ItemStaffFire.java index 00bbfab..5963c20 100644 --- a/common/MysticWorld/Items/ItemStaffFire.java +++ b/common/MysticWorld/Items/ItemStaffFire.java @@ -1,19 +1,25 @@ package MysticWorld.Items; +import java.util.Random; + import org.lwjgl.input.Keyboard; import MysticWorld.MysticWorld; import MysticWorld.Blocks.BlockHandler; import MysticWorld.Entity.EntityChargeFire; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumMovingObjectType; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class ItemStaffFire extends Item { @@ -54,69 +60,124 @@ public class ItemStaffFire extends Item { return true; } - - public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int par4, int par5, int par6, int par7, float par8, float par9, float par10){ - if (par7 == 0) - { - --par5; - } - - if (par7 == 1) - { - ++par5; - } - - if (par7 == 2) - { - --par6; - } - - if (par7 == 3) - { - ++par6; - } - - if (par7 == 4) - { - --par4; - } - - if (par7 == 5) - { - ++par4; - } - - if (!entityPlayer.canPlayerEdit(par4, par5, par6, par7, itemStack)) - { - return false; - } - else - { - int i1 = world.getBlockId(par4, par5, par6); - - if (i1 == 0) - { - world.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); - world.setBlock(par4, par5, par6, Block.fire.blockID); - } - - itemStack.damageItem(1, entityPlayer); - return true; - } - } public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { - world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0); - - if (!world.isRemote) - { - world.spawnEntityInWorld(new EntityChargeFire(world, entityPlayer)); - - itemStack.damageItem(1, entityPlayer); - } - - return itemStack; + if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, entityPlayer, true); + + Random rand = new Random(); + + if (movingobjectposition == null) + { + return itemStack; + } + else + { + if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!world.canMineBlock(entityPlayer, i, j, k)) + { + return itemStack; + } + + if (!entityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, itemStack)) + { + return itemStack; + } + else + { + if (world.getBlockId(i, j, k) == Block.cobblestone.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, Block.stone.blockID); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.oreIron.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, 0); + world.spawnEntityInWorld(new EntityItem(world, i, j, k, new ItemStack(Item.ingotIron, 1))); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.oreGold.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, 0); + world.spawnEntityInWorld(new EntityItem(world, i, j, k, new ItemStack(Item.ingotGold, 1))); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.sand.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, Block.glass.blockID); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.netherrack.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, 0); + world.spawnEntityInWorld(new EntityItem(world, i, j, k, new ItemStack(Item.netherrackBrick, 1))); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.wood.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, 0); + world.spawnEntityInWorld(new EntityItem(world, i, j, k, new ItemStack(Item.coal, 1, 1))); + itemStack.damageItem(1, entityPlayer); + } + } + else if (world.getBlockId(i, j, k) == Block.cactus.blockID) + { + if (!world.isRemote) + { + world.playSoundEffect((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + world.setBlock(i, j, k, 0); + world.spawnEntityInWorld(new EntityItem(world, i, j, k, new ItemStack(Item.dyePowder, 1, 2))); + itemStack.damageItem(1, entityPlayer); + } + } + } + } + } + } + else + { + world.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)entityPlayer.posX, (int)entityPlayer.posY, (int)entityPlayer.posZ, 0); + + if (!world.isRemote) + { + world.spawnEntityInWorld(new EntityChargeFire(world, entityPlayer)); + + itemStack.damageItem(1, entityPlayer); + } + + return itemStack; + } + return itemStack; } }