use of am2.blocks.tileentities.TileEntityCraftingAltar in project ArsMagica2 by Mithion.
the class AMPacketProcessorClient method handleCraftingAltarData.
private void handleCraftingAltarData(byte[] data) {
AMDataReader rdr = new AMDataReader(data, false);
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(rdr.getInt(), rdr.getInt(), rdr.getInt());
if (te == null || !(te instanceof TileEntityCraftingAltar))
return;
((TileEntityCraftingAltar) te).HandleUpdatePacket(rdr.getRemainingBytes());
}
use of am2.blocks.tileentities.TileEntityCraftingAltar in project ArsMagica2 by Mithion.
the class BlockCraftingAltar method getAltarMimicBlock.
@SideOnly(Side.CLIENT)
public Block getAltarMimicBlock(IBlockAccess world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te == null || !(te instanceof TileEntityCraftingAltar) || !((TileEntityCraftingAltar) te).structureValid())
return this;
Block[] blocks = new Block[4];
blocks[0] = world.getBlock(x - 1, y, z);
blocks[1] = world.getBlock(x + 1, y, z);
blocks[2] = world.getBlock(x, y, z + 1);
blocks[3] = world.getBlock(x, y, z - 1);
if (blocks[0] != Blocks.air && blocks[0] == blocks[1]) {
return blocks[0];
} else if (blocks[2] != Blocks.air && blocks[2] == blocks[3]) {
return blocks[2];
}
return this;
}
use of am2.blocks.tileentities.TileEntityCraftingAltar in project ArsMagica2 by Mithion.
the class EntityAISpellmaking method updateTask.
@Override
public void updateTask() {
AMVector3 targetLocation = host.getSearchLocation();
AMVector3 dropLocation = host.getDropLocation();
AMVector3 hostLocation = new AMVector3(host);
ItemStack searchItem = host.getSearchItem();
if (searchItem.getItem() == ItemsCommonProxy.essence && searchItem.getItemDamage() > ItemsCommonProxy.essence.META_MAX) {
TileEntityCraftingAltar altar = host.getAltarTarget();
if (altar.switchIsOn())
return;
BlockCoord bc = altar.getSwitchLocation();
if (action_state == 0 && host.getNavigator().noPath()) {
host.getNavigator().tryMoveToXYZ(altar.xCoord + bc.x, altar.yCoord + bc.y, altar.zCoord + bc.z, MOVE_SPEED);
} else if (action_state == 0 && hostLocation.distanceSqTo(new AMVector3(altar.xCoord + bc.x, altar.yCoord + bc.y, altar.zCoord + bc.z)) < DISTANCE_THRESHOLD) {
action_state = 1;
altar.flipSwitch();
wait_counter = 0;
} else if (action_state == 1 && wait_counter < WAIT_TIME) {
wait_counter++;
} else if (action_state == 1 && wait_counter >= WAIT_TIME) {
resetTask();
}
} else {
if (action_state == 0 && host.getNavigator().noPath()) {
//no item and too far away to grab
host.getNavigator().tryMoveToXYZ(targetLocation.x, targetLocation.y, targetLocation.z, MOVE_SPEED);
} else if (action_state == 0 && hostLocation.distanceSqTo(targetLocation) < DISTANCE_THRESHOLD) {
host.getNavigator().clearPathEntity();
TileEntity te = host.worldObj.getTileEntity((int) targetLocation.x, (int) targetLocation.y, (int) targetLocation.z);
if (te == null || !(te instanceof IInventory)) {
resetTask();
return;
}
((IInventory) te).openInventory();
if (!host.worldObj.isRemote)
InventoryUtilities.deductFromInventory(((IInventory) te), host.getSearchItem(), 1);
host.setHeldItem(host.getSearchItem());
action_state = 1;
} else if (action_state == 1 && host.getNavigator().noPath() && wait_counter < WAIT_TIME) {
wait_counter++;
} else if (action_state == 1 && host.getNavigator().noPath() && wait_counter >= WAIT_TIME) {
wait_counter = 0;
TileEntity te = host.worldObj.getTileEntity((int) targetLocation.x, (int) targetLocation.y, (int) targetLocation.z);
if (te == null || !(te instanceof IInventory)) {
resetTask();
return;
}
((IInventory) te).closeInventory();
host.getNavigator().tryMoveToXYZ(dropLocation.x, dropLocation.y, dropLocation.z, MOVE_SPEED);
} else if (action_state == 1 && hostLocation.distanceSqTo(dropLocation) < DISTANCE_THRESHOLD) {
host.getNavigator().clearPathEntity();
if (!host.worldObj.isRemote) {
EntityItem droppedItem = host.entityDropItem(host.getSearchItem(), 0f);
host.setHeldItem(new ItemStack(Items.paper));
}
action_state = 2;
} else if (action_state == 2 && wait_counter < WAIT_TIME) {
wait_counter++;
} else if (action_state == 2 && wait_counter >= WAIT_TIME) {
resetTask();
}
}
}
Aggregations