use of am2.containers.ContainerSpellCustomization in project ArsMagica2 by Mithion.
the class AMPacketProcessorServer method handleSpellCustomize.
private void handleSpellCustomize(byte[] data, EntityPlayerMP player) {
AMDataReader rdr = new AMDataReader(data, false);
int entityID = rdr.getInt();
EntityLivingBase ent = getEntityByID(entityID);
if (player == null) {
return;
}
int IIconIndex = rdr.getInt();
String name = rdr.getString();
if (player.openContainer instanceof ContainerSpellCustomization) {
((ContainerSpellCustomization) player.openContainer).setNameAndIndex(name, IIconIndex);
}
}
use of am2.containers.ContainerSpellCustomization in project ArsMagica2 by Mithion.
the class GuiSpellCustomization method initGui.
@Override
public void initGui() {
super.initGui();
int l = (width - xSize) / 2;
int i1 = (height - ySize) / 2;
if (AMCore.config.suggestSpellNames())
spellName = new GuiTextField(fontRendererObj, l + 8, i1 + 8, xSize - 36, 16);
else
spellName = new GuiTextField(fontRendererObj, l + 8, i1 + 8, xSize - 16, 16);
String suggestion = ((ContainerSpellCustomization) this.inventorySlots).getInitialSuggestedName();
spellName.setText(suggestion);
if (!suggestion.equals("")) {
curName = suggestion;
((ContainerSpellCustomization) this.inventorySlots).setNameAndIndex(curName, curIndex);
}
btnPrev = new GuiButtonVariableDims(0, l + 8, i1 + 26, StatCollector.translateToLocal("am2.gui.prev")).setDimensions(48, 20);
btnNext = new GuiButtonVariableDims(1, l + xSize - 56, i1 + 26, StatCollector.translateToLocal("am2.gui.next")).setDimensions(48, 20);
btnRandomName = new GuiButtonVariableDims(2, l + xSize - 24, i1 + 5, "???");
btnRandomName.setDimensions(20, 20);
this.buttonList.add(btnPrev);
this.buttonList.add(btnNext);
if (AMCore.config.suggestSpellNames())
this.buttonList.add(btnRandomName);
int IIcon_start_x = l + 12;
int IIcon_start_y = i1 + 50;
int btnX = IIcon_start_x;
int btnY = IIcon_start_y;
int id = 3;
int IIconCount = 0;
int curPage = 0;
for (IIcon icon : SpellTextureHelper.instance.getAllIcons()) {
GuiSpellImageButton spellButton = new GuiSpellImageButton(id++, btnX, btnY, icon, IIconCount++, curPage);
if (curPage != 0) {
spellButton.visible = false;
}
this.buttonList.add(spellButton);
btnX += 14;
if (btnX > (l + xSize) - 15) {
btnX = IIcon_start_x;
btnY += 14;
if (btnY > (i1 + ySize - 10)) {
btnY = IIcon_start_y;
curPage++;
}
}
}
this.numPages = curPage;
}
use of am2.containers.ContainerSpellCustomization in project ArsMagica2 by Mithion.
the class ServerGuiManager method getServerGuiElement.
@Override
public Object getServerGuiElement(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 ContainerEssenceRefiner(player.inventory, (TileEntityEssenceRefiner) te);
case ArsMagicaGuiIdList.GUI_SPELL_BOOK:
ItemStack bookStack = player.getCurrentEquippedItem();
if (bookStack.getItem() == null || !(bookStack.getItem() instanceof ItemSpellBook)) {
return null;
}
ItemSpellBook item = (ItemSpellBook) bookStack.getItem();
return new ContainerSpellBook(player.inventory, player.getCurrentEquippedItem(), item.ConvertToInventory(bookStack));
case ArsMagicaGuiIdList.GUI_CALEFACTOR:
if (!(te instanceof TileEntityCalefactor)) {
return null;
}
return new ContainerCalefactor(player, (TileEntityCalefactor) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_LOCKABLE:
if (!(te instanceof IKeystoneLockable)) {
return null;
}
return new ContainerKeystoneLockable(player.inventory, (IKeystoneLockable) te);
case ArsMagicaGuiIdList.GUI_ASTRAL_BARRIER:
if (!(te instanceof TileEntityAstralBarrier)) {
return null;
}
return new ContainerAstralBarrier(player.inventory, (TileEntityAstralBarrier) te);
case ArsMagicaGuiIdList.GUI_SEER_STONE:
if (!(te instanceof TileEntitySeerStone)) {
return null;
}
return new ContainerSeerStone(player.inventory, (TileEntitySeerStone) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE_CHEST:
if (!(te instanceof TileEntityKeystoneChest)) {
return null;
}
return new ContainerKeystoneChest(player.inventory, (TileEntityKeystoneChest) te);
case ArsMagicaGuiIdList.GUI_KEYSTONE:
ItemStack keystoneStack = player.getCurrentEquippedItem();
if (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 ContainerKeystone(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 ContainerEssenceBag(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 ContainerRuneBag(player.inventory, player.getCurrentEquippedItem(), runebag.ConvertToInventory(bagStack));
case ArsMagicaGuiIdList.GUI_ARCANE_RECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneReconstructor)) {
return null;
}
return new ContainerArcaneReconstructor(player.inventory, (TileEntityArcaneReconstructor) te);
case ArsMagicaGuiIdList.GUI_INSCRIPTION_TABLE:
if (!(te instanceof TileEntityInscriptionTable)) {
return null;
}
return new ContainerInscriptionTable((TileEntityInscriptionTable) te, player.inventory);
case ArsMagicaGuiIdList.GUI_SUMMONER:
if (!(te instanceof TileEntitySummoner)) {
return null;
}
return new ContainerSummoner(player.inventory, (TileEntitySummoner) te);
case ArsMagicaGuiIdList.GUI_MAGICIANS_WORKBENCH:
if (!(te instanceof TileEntityMagiciansWorkbench)) {
return null;
}
return new ContainerMagiciansWorkbench(player.inventory, (TileEntityMagiciansWorkbench) te);
case ArsMagicaGuiIdList.GUI_RIFT:
return new ContainerRiftStorage(player.inventory, RiftStorage.For(player));
case ArsMagicaGuiIdList.GUI_SPELL_CUSTOMIZATION:
return new ContainerSpellCustomization(player);
case ArsMagicaGuiIdList.GUI_CRYSTAL_MARKER:
if (!(te instanceof TileEntityCrystalMarker)) {
return null;
}
return new ContainerCrystalMarker(player, (TileEntityCrystalMarker) te);
case ArsMagicaGuiIdList.GUI_OBELISK:
if (!(te instanceof TileEntityObelisk)) {
return null;
}
return new ContainerObelisk((TileEntityObelisk) te, player);
case ArsMagicaGuiIdList.GUI_FLICKER_HABITAT:
if (!(te instanceof TileEntityFlickerHabitat)) {
return null;
}
return new ContainerFlickerHabitat(player, (TileEntityFlickerHabitat) te);
case ArsMagicaGuiIdList.GUI_ARMOR_INFUSION:
if (!(te instanceof TileEntityArmorImbuer)) {
return null;
}
return new ContainerArmorInfuser(player, (TileEntityArmorImbuer) te);
case ArsMagicaGuiIdList.GUI_ARCANE_DECONSTRUCTOR:
if (!(te instanceof TileEntityArcaneDeconstructor)) {
return null;
}
return new ContainerArcaneDeconstructor(player.inventory, (TileEntityArcaneDeconstructor) te);
case ArsMagicaGuiIdList.GUI_INERT_SPAWNER:
if (!(te instanceof TileEntityInertSpawner)) {
return null;
}
return new ContainerInertSpawner(player, (TileEntityInertSpawner) te);
case ArsMagicaGuiIdList.GUI_SPELL_SEALED_DOOR:
if (!(te instanceof TileEntitySpellSealedDoor)) {
return null;
}
return new ContainerSpellSealedDoor(player.inventory, (TileEntitySpellSealedDoor) te);
}
return null;
}
Aggregations