use of WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone in project BloodMagic by WayofTime.
the class ItemRitualDismantler method breakRitualStoneAtMasterStone.
public boolean breakRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TEMasterStone) {
TEMasterStone masterStone = (TEMasterStone) tileEntity;
int direction = masterStone.getDirection();
String ritualName = Rituals.checkValidRitual(world, x, y, z);
List<RitualComponent> ritualList = Rituals.getRitualList(ritualName);
if (ritualList == null) {
return false;
}
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 (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.playAuxSFX(2005, x, y + 1, z, 0);
} else {
world.spawnEntityInWorld(entityItem);
}
}
}
}
return true;
}
return false;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone in project BloodMagic by WayofTime.
the class ItemRitualDiviner method placeRitualStoneAtMasterStone.
public boolean placeRitualStoneAtMasterStone(ItemStack stack, EntityPlayer player, World world, int x, int y, int z) {
int direction = this.getDirection(stack);
ItemStack[] playerInventory = player.inventory.mainInventory;
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TEMasterStone) {
List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(stack));
if (ritualList == null) {
return false;
}
int playerInvRitualStoneLocation = -1;
for (int i = 0; i < playerInventory.length; i++) {
if (playerInventory[i] == null) {
continue;
}
if (new ItemStack(ModBlocks.ritualStone).isItemEqual(playerInventory[i])) {
playerInvRitualStoneLocation = i;
break;
}
}
for (RitualComponent rc : ritualList) {
if (world.isAirBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction))) {
if (playerInvRitualStoneLocation >= 0 || player.capabilities.isCreativeMode) {
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
world.playAuxSFX(200, x, y + 1, z, 0);
return true;
}
if (!player.capabilities.isCreativeMode) {
player.inventory.decrStackSize(playerInvRitualStoneLocation, 1);
}
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
world.setBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), ModBlocks.ritualStone, rc.getStoneType(), 3);
if (world.isRemote) {
world.playAuxSFX(2005, x, y + 1, z, 0);
return true;
}
}
return true;
}
} else {
Block block = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
if (block == ModBlocks.ritualStone) {
int metadata = world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
if (metadata != rc.getStoneType()) {
if (EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(stack)) {
world.playAuxSFX(200, x, y + 1, z, 0);
return true;
}
world.setBlockMetadataWithNotify(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction), rc.getStoneType(), 3);
return true;
}
}
} else {
world.playAuxSFX(0, x, y + 1, z, 0);
return true;
}
}
}
}
return false;
}
Aggregations