use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class ClientGuiManager method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te == null && ID != ArsMagicaGuiIdList.GUI_SPELL_BOOK && ID != ArsMagicaGuiIdList.GUI_KEYSTONE && ID != ArsMagicaGuiIdList.GUI_ESSENCE_BAG && ID != ArsMagicaGuiIdList.GUI_RUNE_BAG && ID != ArsMagicaGuiIdList.GUI_RIFT && ID != ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION) {
return null;
}
switch(ID) {
case ArsMagicaGuiIdList.GUI_ESSENCE_REFINER:
if (!(te instanceof TileEntityEssenceRefiner)) {
return null;
}
return new GuiEssenceRefiner(player.inventory, (TileEntityEssenceRefiner) te);
case ArsMagicaGuiIdList.GUI_SPELL_BOOK:
ItemStack bookStack = player.getCurrentEquippedItem();
if (bookStack == null || bookStack.getItem() == null || !(bookStack.getItem() instanceof ItemSpellBook)) {
return null;
}
ItemSpellBook item = (ItemSpellBook) bookStack.getItem();
return new GuiSpellBook(player.inventory, player.getCurrentEquippedItem(), item.ConvertToInventory(bookStack));
case ArsMagicaGuiIdList.GUI_CALEFACTOR:
if (!(te instanceof TileEntityCalefactor)) {
return null;
}
return new GuiCalefactor(player, (TileEntityCalefactor) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_LOCKABLE:
if (!(te instanceof IKeystoneLockable)) {
return null;
}
return new GuiKeystoneLockable(player.inventory, (IKeystoneLockable) te);
case ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER:
if (!(te instanceof TileEntityAstralBarrier)) {
return null;
}
return new GuiAstralBarrier(player.inventory, (TileEntityAstralBarrier) te);
case ArsMagicaGuiIdList.GUI_SEER_STONE:
if (!(te instanceof TileEntitySeerStone)) {
return null;
}
return new GuiSeerStone(player.inventory, (TileEntitySeerStone) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_CHEST:
if (!(te instanceof TileEntityKeystoneChest)) {
return null;
}
return new GuiKeystoneChest(player.inventory, (TileEntityKeystoneChest) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE:
ItemStack keystoneStack = player.getCurrentEquippedItem();
if (keystoneStack == null || keystoneStack.getItem() == null || !(keystoneStack.getItem() instanceof ItemKeystone)) {
return null;
}
ItemKeystone keystone = (ItemKeystone) keystoneStack.getItem();
int runeBagSlot = InventoryUtilities.getInventorySlotIndexFor(player.inventory, ItemsCommonProxy.runeBag);
ItemStack runeBag = null;
if (runeBagSlot > -1)
runeBag = player.inventory.getStackInSlot(runeBagSlot);
return new GuiKeystone(player.inventory, player.getCurrentEquippedItem(), runeBag, keystone.ConvertToInventory(keystoneStack), runeBag == null ? null : ItemsCommonProxy.runeBag.ConvertToInventory(runeBag), runeBagSlot);
case ArsMagicaGuiIdList.GUI_ESSENCE_BAG:
ItemStack bagStack = player.getCurrentEquippedItem();
if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemEssenceBag)) {
return null;
}
ItemEssenceBag bag = (ItemEssenceBag) bagStack.getItem();
return new GuiEssenceBag(player.inventory, player.getCurrentEquippedItem(), bag.ConvertToInventory(bagStack));
case ArsMagicaGuiIdList.GUI_RUNE_BAG:
bagStack = player.getCurrentEquippedItem();
if (bagStack.getItem() == null || !(bagStack.getItem() instanceof ItemRuneBag)) {
return null;
}
ItemRuneBag runebag = (ItemRuneBag) bagStack.getItem();
return new GuiRuneBag(player.inventory, player.getCurrentEquippedItem(), runebag.ConvertToInventory(bagStack));
case ArsMagicaGuiIdList.GUI_ARCANE_RECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneReconstructor)) {
return null;
}
return new GuiArcaneReconstructor(player.inventory, (TileEntityArcaneReconstructor) te);
case ArsMagicaGuiIdList.GUI_SUMMONER:
if (!(te instanceof TileEntitySummoner)) {
return null;
}
return new GuiSummoner(player.inventory, (TileEntitySummoner) te);
case ArsMagicaGuiIdList.GUI_INSCRIPTION_TABLE:
if (!(te instanceof TileEntityInscriptionTable)) {
return null;
}
return new GuiInscriptionTable(player.inventory, (TileEntityInscriptionTable) te);
case ArsMagicaGuiIdList.GUI_MAGICIANS_WORKBENCH:
if (!(te instanceof TileEntityMagiciansWorkbench)) {
return null;
}
return new GuiMagiciansWorkbench(player.inventory, (TileEntityMagiciansWorkbench) te);
case ArsMagicaGuiIdList.GUI_RIFT:
return new GuiRiftStorage(player.inventory, RiftStorage.For(player));
case ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION:
return new GuiSpellCustomization(player);
case ArsMagicaGuiIdList.GUI_CRYSTAL_MARKER:
if (!(te instanceof TileEntityCrystalMarker)) {
return null;
}
return new GuiCrystalMarker(player, (TileEntityCrystalMarker) te);
case ArsMagicaGuiIdList.GUI_OBELISK:
if (!(te instanceof TileEntityObelisk)) {
return null;
}
return new GuiObelisk((TileEntityObelisk) te, player);
case ArsMagicaGuiIdList.GUI_FLICKER_HABITAT:
if (!(te instanceof TileEntityFlickerHabitat)) {
return null;
}
return new GuiFlickerHabitat(player, (TileEntityFlickerHabitat) te);
case ArsMagicaGuiIdList.GUI_ARMOR_INFUSION:
if (!(te instanceof TileEntityArmorImbuer)) {
return null;
}
return new GuiArmorImbuer(player, (TileEntityArmorImbuer) te);
case ArsMagicaGuiIdList.GUI_ARCANE_DECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneDeconstructor)) {
return null;
}
return new GuiArcaneDeconstructor(player.inventory, (TileEntityArcaneDeconstructor) te);
case ArsMagicaGuiIdList.GUI_INERT_SPAWNER:
if (!(te instanceof TileEntityInertSpawner)) {
return null;
}
return new GuiInertSpawner(player, (TileEntityInertSpawner) te);
case ArsMagicaGuiIdList.GUI_SPELL_SEALED_DOOR:
if (!(te instanceof TileEntitySpellSealedDoor)) {
return null;
}
return new GuiSpellSealedDoor(player.inventory, (TileEntitySpellSealedDoor) te);
}
return null;
}
use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class FlickerOperatorItemTransport method DoOperation.
@Override
public boolean DoOperation(World worldObj, IFlickerController controller, boolean powered, Affinity[] flickers) {
if (worldObj.isRemote) {
return false;
}
// Gets the habitat running this operation
TileEntityFlickerHabitat habitat = null;
if (controller instanceof TileEntityFlickerHabitat) {
habitat = (TileEntityFlickerHabitat) controller;
} else {
// if the habitat couldn't be found, bail
return false;
}
int toMove = 0;
// if(powered){
for (int i = 0; i < 6; i++) {
if (flickers[i] == Affinity.ARCANE) {
toMove += 32;
}
}
// }
// ensure toMove is at least 1
toMove = Math.max(toMove, 1);
// initiate the arrays for any input crystals
ArrayList<ItemStack> itemsToTransfer = new ArrayList<ItemStack>();
ArrayList<AMVector3> removeFromInList = new ArrayList<AMVector3>();
boolean itemFound = false;
// if the in list position has exceeded the size of the list reset it
if (habitat.getInListPosition() >= habitat.getInListSize()) {
habitat.setInListPosition(0);
}
for (int inIterator = habitat.getInListPosition(); inIterator < habitat.getInListSize(); ++inIterator) {
// Gets the tile entity for the attached crystal marker at the specified location
AMVector3 vector = habitat.getInListAt(inIterator);
TileEntity te = null;
TileEntityCrystalMarker crystalMarkerTE = GetCrystalMarkerTileEntity(worldObj, (int) vector.x, (int) vector.y, (int) vector.z);
if (crystalMarkerTE == null) {
// crystal marker no longer exists, remove it from the list
removeFromInList.add(vector);
break;
}
te = GetAttachedCrystalMarkerTileEntity(worldObj, crystalMarkerTE, vector);
if (te != null && te instanceof IInventory) {
// if the crystal is attached to an inventory
itemFound = moveItem(worldObj, (IInventory) te, crystalMarkerTE, habitat, toMove);
if (itemFound) {
// if an item was found the break out of the current loop
habitat.setInListPosition(inIterator + 1);
break;
} else if (te instanceof TileEntityChest) {
// This is to handle the special case of double chests
TileEntityChest adjacent = InventoryUtilities.getAdjacentChest((TileEntityChest) te);
if (adjacent != null) {
itemFound = moveItem(worldObj, adjacent, crystalMarkerTE, habitat, toMove);
if (itemFound) {
habitat.setInListPosition(inIterator + 1);
}
}
}
}
}
if (itemFound == false) {
// if no items were found to move then reset the input list position
habitat.setInListPosition(0);
}
for (AMVector3 vector : removeFromInList) {
// remove the invalid in list positions from the maintained in list
habitat.removeInListAt(vector);
}
return itemFound;
}
use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class FlickerOperatorItemTransport method moveItem.
private boolean moveItem(World worldObj, IInventory inventory, TileEntityCrystalMarker crystalMarkerTE, TileEntityFlickerHabitat habitat, int toMove) {
boolean itemFound = false;
ItemStack orgStack = null;
int currentSlot = 0;
GetFirstStackStartingFromSlotResult result = InventoryUtilities.getFirstStackStartingFromSlot(inventory, orgStack, currentSlot, crystalMarkerTE.getFacing());
orgStack = result.stack;
currentSlot = result.slot;
while (orgStack != null) {
if (orgStack != null && InputCanMove(crystalMarkerTE, orgStack, inventory)) {
ItemStack stackCopy = orgStack.copy();
int amountToMove = Math.min(toMove, stackCopy.stackSize);
ItemStack mergeStack = stackCopy.splitStack(amountToMove);
if (FindOutput(worldObj, habitat, mergeStack, inventory)) {
// if a valid item was found in input, and a valid output for it was found remove the item from the source
InventoryUtilities.deductFromInventory(inventory, orgStack, amountToMove - mergeStack.stackSize);
itemFound = true;
break;
} else {
currentSlot++;
}
} else {
currentSlot++;
}
result = InventoryUtilities.getFirstStackStartingFromSlot(inventory, orgStack, currentSlot, crystalMarkerTE.getFacing());
orgStack = result.stack;
currentSlot = result.slot;
if (currentSlot == -1) {
orgStack = null;
}
}
return itemFound;
}
use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class AMClientEventHandler method renderPriorityText.
private void renderPriorityText(DrawBlockHighlightEvent event, TileEntityCrystalMarker te) {
int meta = event.player.worldObj.getBlockMetadata(event.target.blockX, event.target.blockY, event.target.blockZ);
if (// no priority for these blocks
meta == BlockCrystalMarker.META_IN)
return;
Block block = event.player.worldObj.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
float yOff = 0.5f;
String priString = String.format(StatCollector.translateToLocal("am2.tooltip.priority"), String.format("%d", te.getPriority()));
AMVector3 boundsOffset = new AMVector3(block.getBlockBoundsMinX() + (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX()) / 2, block.getBlockBoundsMinY() + (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY()) / 2, block.getBlockBoundsMinZ() + (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ()) / 2);
AMVector3 offset = new AMVector3(event.target.blockX + boundsOffset.x, event.target.blockY + boundsOffset.y, event.target.blockZ + boundsOffset.z).sub(new AMVector3((event.player.prevPosX - (event.player.prevPosX - event.player.posX) * event.partialTicks), (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) + event.player.getEyeHeight(), (event.player.prevPosZ - (event.player.prevPosZ - event.player.posZ) * event.partialTicks)));
offset = offset.normalize();
AMVector3 drawPos = new AMVector3(event.target.blockX + block.getBlockBoundsMaxX() - offset.x - (event.player.prevPosX - (event.player.prevPosX - event.player.posX) * event.partialTicks), event.target.blockY + yOff - (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) + block.getBlockBoundsMaxY() * 0.8f, event.target.blockZ + block.getBlockBoundsMaxZ() - offset.z - (event.player.prevPosZ - (event.player.prevPosZ - event.player.posZ) * event.partialTicks));
if (event.target.blockY > event.player.posY - 0.5) {
drawPos.y = (float) (event.target.blockY - yOff - (event.player.prevPosY - (event.player.prevPosY - event.player.posY) * event.partialTicks) - block.getBlockBoundsMaxY() * 0.2f);
}
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
RenderUtilities.drawTextInWorldAtOffset(priString, drawPos.x, drawPos.y, drawPos.z, 0xFFFFFF);
GL11.glPopAttrib();
}
use of am2.blocks.tileentities.TileEntityCrystalMarker in project ArsMagica2 by Mithion.
the class BlockCrystalMarker method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block oldBlock, int oldMeta) {
TileEntityCrystalMarker crystalMarkerTE = GetTileEntity(world, x, y, z);
TileEntityFlickerHabitat elementalAttunerTE = null;
if (crystalMarkerTE != null) {
AMVector3 elementalAttunerVector = crystalMarkerTE.getElementalAttuner();
if (elementalAttunerVector != null) {
elementalAttunerTE = GetElementalAttunerTileEntity(world, (int) elementalAttunerVector.x, (int) elementalAttunerVector.y, (int) elementalAttunerVector.z);
if (elementalAttunerTE != null) {
int operandType = world.getBlockMetadata(x, y, z);
if (operandType == META_IN) {
elementalAttunerTE.removeInMarkerLocation(x, y, z);
} else if (isOutputMarker(operandType)) {
elementalAttunerTE.removeOutMarkerLocation(x, y, z);
}
}
}
}
super.breakBlock(world, x, y, z, oldBlock, oldMeta);
}
Aggregations