commit
1ca7795164
1 changed files with 10 additions and 19 deletions
|
@ -9,6 +9,7 @@ import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -49,14 +50,12 @@ public class ItemRitualDismantler extends EnergyItems
|
||||||
|
|
||||||
public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z)
|
public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
ItemStack[] playerInventory = player.inventory.mainInventory;
|
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity instanceof TEMasterStone)
|
if (tileEntity instanceof TEMasterStone)
|
||||||
{
|
{
|
||||||
TEMasterStone masterStone = (TEMasterStone) tileEntity;
|
TEMasterStone masterStone = (TEMasterStone) tileEntity;
|
||||||
int direction = masterStone.getDirection();
|
int direction = masterStone.getDirection();
|
||||||
int freeSpace = -1;
|
|
||||||
|
|
||||||
String ritualName = Rituals.checkValidRitual(world, x, y, z);
|
String ritualName = Rituals.checkValidRitual(world, x, y, z);
|
||||||
List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
|
List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
|
||||||
|
@ -65,29 +64,21 @@ public class ItemRitualDismantler extends EnergyItems
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < playerInventory.length; i++)
|
|
||||||
{
|
|
||||||
if (playerInventory[i] == null)
|
|
||||||
{
|
|
||||||
freeSpace = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (RitualComponent rc : ritualList)
|
for (RitualComponent rc : ritualList)
|
||||||
{
|
{
|
||||||
if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) instanceof RitualStone)
|
if (!world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) && world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)) instanceof RitualStone)
|
||||||
{
|
{
|
||||||
if (freeSpace >= 0)
|
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed()) || player.capabilities.isCreativeMode)
|
world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
|
||||||
|
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(ModBlocks.ritualStone));
|
||||||
|
if (world.isRemote)
|
||||||
{
|
{
|
||||||
world.setBlockToAir(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
|
world.playAuxSFX(2005, x, y + 1, z, 0);
|
||||||
player.inventory.addItemStackToInventory(new ItemStack(ModBlocks.ritualStone));
|
}
|
||||||
if (world.isRemote)
|
else
|
||||||
{
|
{
|
||||||
world.playAuxSFX(2005, x, y + 1, z, 0);
|
world.spawnEntityInWorld(entityItem);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue