Added in awesome smelting code for fire staff!
This commit is contained in:
parent
e8b4d9ad2a
commit
ed93305639
4 changed files with 31 additions and 76 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package MysticWorld.Items;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
|
@ -17,6 +18,7 @@ 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.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
|
@ -66,8 +68,6 @@ public class ItemStaffFire extends Item {
|
|||
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)
|
||||
{
|
||||
|
|
@ -80,7 +80,7 @@ public class ItemStaffFire extends Item {
|
|||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
|
||||
if (!world.canMineBlock(entityPlayer, i, j, k))
|
||||
{
|
||||
return itemStack;
|
||||
|
|
@ -92,74 +92,18 @@ public class ItemStaffFire extends Item {
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(world.getBlockId(i, j, k), 1, world.getBlockMetadata(i, j, k)));
|
||||
|
||||
int id = result.itemID;
|
||||
int meta = result.getItemDamage();
|
||||
|
||||
if (!world.isRemote && !(result == null))
|
||||
{
|
||||
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(id, 1, meta)));
|
||||
itemStack.damageItem(1, entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue