use of WayofTime.alchemicalWizardry.common.tileEntity.TESocket in project BloodMagic by WayofTime.
the class ArmourForge method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) {
if (world.isRemote) {
return false;
}
int armourType = getArmourType(world, x, y, z);
if (armourType == -1) {
return false;
}
int direction = getDirectionForArmourType(world, x, y, z, armourType);
if (!isParadigmValid(armourType, direction, world, x, y, z)) {
return false;
}
List<ArmourComponent> list = null;
ItemStack armourPiece = null;
switch(armourType) {
case 0:
list = plateList;
armourPiece = new ItemStack(ModItems.boundPlate, 1, 0);
break;
case 1:
list = leggingsList;
armourPiece = new ItemStack(ModItems.boundLeggings, 1, 0);
break;
case 2:
list = helmetList;
armourPiece = new ItemStack(ModItems.boundHelmet, 1, 0);
break;
case 3:
list = bootsList;
armourPiece = new ItemStack(ModItems.boundBoots, 1, 0);
break;
}
if (list == null) {
return false;
}
if (armourPiece == null) {
return false;
}
if (armourPiece.getTagCompound() == null) {
armourPiece.setTagCompound(new NBTTagCompound());
}
for (ArmourComponent ac : list) {
int xOff = ac.getXOff();
int zOff = ac.getZOff();
TileEntity tileEntity;
switch(direction) {
case 1:
tileEntity = world.getTileEntity(x + xOff, y, z - zOff);
break;
case 2:
tileEntity = world.getTileEntity(x + zOff, y, z + xOff);
break;
case 3:
tileEntity = world.getTileEntity(x - xOff, y, z + zOff);
break;
case 4:
tileEntity = world.getTileEntity(x - zOff, y, z - xOff);
break;
case 5:
tileEntity = world.getTileEntity(x + xOff, y + zOff, z);
break;
case 6:
tileEntity = world.getTileEntity(x, y + zOff, z + xOff);
break;
default:
tileEntity = null;
}
if (tileEntity instanceof TESocket) {
ItemStack itemStack = ((TESocket) tileEntity).getStackInSlot(0);
int xCoord = tileEntity.xCoord;
int yCoord = tileEntity.yCoord;
int zCoord = tileEntity.zCoord;
((TESocket) tileEntity).setInventorySlotContents(0, null);
world.setBlockToAir(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
for (int i = 0; i < 8; i++) {
SpellHelper.sendIndexedParticleToAllAround(world, xCoord, yCoord, zCoord, 20, world.provider.dimensionId, 1, xCoord, yCoord, zCoord);
}
if (itemStack != null) {
Item item = itemStack.getItem();
if (item instanceof ArmourUpgrade) {
((BoundArmour) armourPiece.getItem()).hasAddedToInventory(armourPiece, itemStack.copy());
((TESocket) tileEntity).setInventorySlotContents(0, null);
}
}
}
}
if (armourPiece != null) {
int xOff = (world.rand.nextInt(11) - 5);
int zOff = (int) (Math.sqrt(25 - xOff * xOff) * (world.rand.nextInt(2) - 0.5) * 2);
world.addWeatherEffect(new EntityLightningBolt(world, x + xOff, y + 5, z + zOff));
world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, armourPiece));
}
return true;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TESocket in project BloodMagic by WayofTime.
the class ArmourForge method isParadigmValid.
public boolean isParadigmValid(int armourType, int direction, World world, int x, int y, int z) {
List<ArmourComponent> list = null;
switch(armourType) {
case 0:
list = plateList;
break;
case 1:
list = leggingsList;
break;
case 2:
list = helmetList;
break;
case 3:
list = bootsList;
break;
}
if (list == null) {
return false;
}
for (ArmourComponent ac : list) {
int xOff = ac.getXOff();
int zOff = ac.getZOff();
switch(direction) {
case 1:
if (!(world.getTileEntity(x + xOff, y, z - zOff) instanceof TESocket)) {
return false;
}
break;
case 2:
if (!(world.getTileEntity(x + zOff, y, z + xOff) instanceof TESocket)) {
return false;
}
break;
case 3:
if (!(world.getTileEntity(x - xOff, y, z + zOff) instanceof TESocket)) {
return false;
}
break;
case 4:
if (!(world.getTileEntity(x - zOff, y, z - xOff) instanceof TESocket)) {
return false;
}
break;
case 5:
if (!(world.getTileEntity(x + xOff, y + zOff, z) instanceof TESocket)) {
return false;
}
break;
case 6:
if (!(world.getTileEntity(x, y + zOff, z + xOff) instanceof TESocket)) {
return false;
}
break;
default:
return false;
}
}
return true;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TESocket in project BloodMagic by WayofTime.
the class BlockSocket method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) {
TESocket tileEntity = (TESocket) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking()) {
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (tileEntity.getStackInSlot(0) == null && playerItem != null) {
if (playerItem.getItem() instanceof ArmourUpgrade) {
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
return true;
} else {
return false;
}
} else if (tileEntity.getStackInSlot(0) != null && playerItem == null) {
player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
tileEntity.setInventorySlotContents(0, null);
tileEntity.setActive();
return true;
}
world.markBlockForUpdate(x, y, z);
return false;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TESocket in project BloodMagic by WayofTime.
the class SigilLava method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote || !EnergyItems.checkAndSetItemOwner(stack, player) || player.isSneaking()) {
return false;
}
if (!world.canMineBlock(player, x, y, z)) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IFluidHandler) {
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, false);
if (amount > 0 && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, true);
}
return false;
} else if (tile instanceof TESocket) {
return false;
}
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}
if (this.canPlaceContainedLiquid(world, x, y, z, x, y, z) && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
return this.tryPlaceContainedLiquid(world, x, y, z, x, y, z);
}
}
return false;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TESocket in project BloodMagic by WayofTime.
the class SigilWater method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (world.isRemote || !EnergyItems.checkAndSetItemOwner(stack, player) || player.isSneaking()) {
return false;
}
if (!world.canMineBlock(player, x, y, z)) {
return false;
}
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IFluidHandler) {
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, false);
if (amount > 0 && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(side), fluid, true);
}
return false;
} else if (tile instanceof TESocket) {
return false;
}
{
if (side == 0) {
--y;
}
if (side == 1) {
++y;
}
if (side == 2) {
--z;
}
if (side == 3) {
++z;
}
if (side == 4) {
--x;
}
if (side == 5) {
++x;
}
if (!player.canPlayerEdit(x, y, z, side, stack)) {
return false;
}
if (this.canPlaceContainedLiquid(world, x, y, z, x, y, z) && EnergyItems.syphonBatteries(stack, player, getEnergyUsed())) {
return this.tryPlaceContainedLiquid(world, x, y, z, x, y, z);
}
}
return false;
}
Aggregations