Jump to content

yorkeMC

Members
  • Posts

    48
  • Joined

  • Last visited

Posts posted by yorkeMC

  1. Hello! I am attempting to render an effect on the player when they have a specific item in their inventory, however, other players on the server cannot see this effect because their clients can't see that the other player has the item in their inventory. How can I sync the player's inventory to other players on a server?

     

    Code:

    Render method, called from the ClientProxy

    Spoiler

            if (p.getActivePotionEffect(MobEffects.INVISIBILITY) != null) return;
            List<Item> rendering = new ArrayList<Item>();

            ItemStack[] inv = p.inventory.mainInventory;
            for (int i = 0; i < 36; i++)
            {
                ItemStack s = inv;
                if (s != null && s.getItem() instanceof IRenderInventoryItem && !rendering.contains(s.getItem()))
                {
                    ((IRenderInventoryItem) s.getItem()).render(p, s, pt);
                    rendering.add(s.getItem());
                }
                if (i == 36) rendering.clear();
            }

     

  2. My custom bow is not spawning an entity when I call world.spawnEntityInWorld(entity). I have even tried with other entities that are not arrows and they are still not spawning in the world. Help please?

     

    CLASS

     

     

    public class ItemAlfbow extends ItemBow implements IRelic, ICraftSoundEffect, IAethericActivity

    {

    // HUD

    public static boolean inside = false;

    public static float ticksHovered = 0F;

    public static List<String> HUDData = new ArrayList<String>();

     

    private static IIcon[] icons = new IIcon[3];

    public static IIcon iconArrow;

     

    public ItemAlfbow ()

    {

    super();

    this.setCreativeTab(Alfhomancy.tabAlfhomancy);

    this.setUnlocalizedName("ItemAlfbow");

    this.setFull3D();

    this.setMaxDamage(-1);

    }

     

    public EnumRarity getRarity (ItemStack s)

    {

    return AlfhomancyAPI.rarityAlfheim;

    }

     

    @Override

    public void addInformation (ItemStack s, EntityPlayer p, List l, boolean f)

    {

    int atk = 0;

    switch (getMode(s))

    {

    case 0 :

    atk = 20;

    break;

    case 1 :

    atk = 20;

    break;

    case 2 :

    atk = 5;

    break;

    case 3 :

    atk = 5;

    break;

    }

     

    l.add(" ");

    l.add(getModeString(s));

    l.add("\u00A7b(" + StatCollector.translateToLocal("text.relic.mode.clickToChange") + ")");

    l.add("\u00A79+" + atk + " " + StatCollector.translateToLocal("text.attackDamage"));

    }

     

    @Override

    @SideOnly (Side.CLIENT)

    public void registerIcons (IIconRegister ir)

    {

    this.itemIcon = ir.registerIcon("alfhomancy:ItemAlfbow");

    this.iconArrow = ir.registerIcon("alfhomancy:ItemAlfbow_arrow");

     

    for (int i = 0; i < 3; i++)

    this.icons = ir.registerIcon("alfhomancy:ItemAlfbow_pulling" + i);

    }

     

    @Override

    public IIcon getIcon (ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)

    {

    if (stack != usingItem) return itemIcon;

     

    int j = (int) ( (getMaxItemUseDuration(stack) - useRemaining) * chargeVelocityMultiplier());

    if (j >= 18) return icons[2];

    if (j > 13) return icons[1];

    if (j > 0) return icons[0];

     

    return itemIcon;

    }

     

    boolean canFire (ItemStack s, World w, EntityPlayer p)

    {

    return AetherHandler.consumeAetherFromInventory(1, p, false);

    }

     

    float chargeVelocityMultiplier ()

    {

    return 1F;

    }

     

    @Override

    public int getMaxItemUseDuration (ItemStack s)

    {

    return 72000;

    }

     

    @Override

    public ItemStack onItemRightClick (ItemStack s, World w, EntityPlayer p)

    {

    ArrowNockEvent event = new ArrowNockEvent(p, s);

    MinecraftForge.EVENT_BUS.post(event);

    event.setCanceled(true);

     

    if (!w.isRemote && p.isSneaking()) toggleMode(s);

    if (!p.isSneaking() && canFire(s, w, p)) p.setItemInUse(s, getMaxItemUseDuration(s));

     

    return s;

    }

     

    @Override

    public void onPlayerStoppedUsing (ItemStack s, World w, EntityPlayer p, int i)

    {

    super.onPlayerStoppedUsing(s, w, p, i);

     

    ArrowLooseEvent event = new ArrowLooseEvent(p, s, i);

    MinecraftForge.EVENT_BUS.post(event);

    event.setCanceled(true);

     

    int j = (int) ( (getMaxItemUseDuration(s) - i) * chargeVelocityMultiplier());

     

    boolean flag = canFire(s, w, p);

     

    if (flag && AetherHandler.consumeAetherFromInventory(1, p, true) && !w.isRemote)

    {

    float f = j / 20.0F;

    f = (f * f + f * 2.0F) / 3.0F;

     

    if (f < 0.1D) return;

     

    if (f > 1.0F) f = 1.0F;

     

    boolean cor = (getMode(s) == 1) || (getMode(s) == 3);

    boolean aoe = (getMode(s) == 2) || (getMode(s) == 3);

     

    spawnArrow(s, w, cor, aoe, 0.0F);

    w.playSoundAtEntity(p, "alfhomancy:swing", 1.0F, 0.3F + (float) Math.random());

    }

    }

     

    private void spawnArrow (ItemStack s, World w, boolean cor, boolean aoe, float f)

    {

    EntityAlfbowArrow e = new EntityAlfbowArrow(w, cor, aoe, f);

    w.spawnEntityInWorld(e);

    }

     

    @Override

    public String getCreator (ItemStack s)

    {

    if (s.getTagCompound() != null) return s.getTagCompound().getString("creator");

    else return null;

    }

     

    @Override

    public boolean isBound (ItemStack s)

    {

    if (s.getTagCompound() != null) return s.getTagCompound().getBoolean("bound");

    else return false;

    }

     

    @Override

    public void bindToCreator (ItemStack s, String n)

    {

    if (s.stackTagCompound == null) s.stackTagCompound = new NBTTagCompound();

     

    if (s.stackTagCompound != null)

    {

    s.stackTagCompound.setBoolean("bound", true);

    s.stackTagCompound.setString("creator", n);

    }

    }

     

    public void toggleMode (ItemStack s)

    {

    if (s.stackTagCompound == null)

    {

    s.setTagCompound(new NBTTagCompound());

    }

    s.stackTagCompound.setInteger("mode", getMode(s) < 3 ? getMode(s) + 1 : 0);

    }

     

    public static int getMode (ItemStack s)

    {

    if (s.stackTagCompound == null)

    {

    return 0;

    }

    return s.stackTagCompound.getInteger("mode");

    }

     

    public static String getModeString (ItemStack s)

    {

    String str = null;

    switch (getMode(s))

    {

    case 0 :

    str = StatCollector.translateToLocal("text.relic.mode.normal");

    break;

    case 1 :

    str = StatCollector.translateToLocal("text.relic.mode.normal") + " \u00A79(" + StatCollector.translateToLocal("text.relic.mode.corrosive") + ")";

    break;

    case 2 :

    str = StatCollector.translateToLocal("text.relic.mode.AoE");

    break;

    case 3 :

    str = StatCollector.translateToLocal("text.relic.mode.AoE") + " \u00A79(" + StatCollector.translateToLocal("text.relic.mode.corrosive") + ")";

    break;

    }

     

    return "\u00A76" + StatCollector.translateToLocal("text.relic.mode") + " \u00A7a" + str;

    }

     

    @Override

    public boolean hasAethericActivity ()

    {

    return true;

    }

     

    @Override

    public boolean isItemPlural ()

    {

    return false;

    }

     

    @Override

    public String getVerbForAethericActivity ()

    {

    return StatCollector.translateToLocal("text.aether.activity.bursting");

    }

     

    @Override

    public boolean soundEffectOnCraft ()

    {

    return true;

    }

    }

     

     

  3. So I am trying to make a recipe class that lets you attach 'spirits' to an item, and you can attach multiple spirits with different metadata, etc. But, for some reason it only works when the item you are attaching to is in a certain slot. I've tried everything I can think of, can anyone help out?

     

    CLASS:

     

     

    package yorkeMC.alfhomancy.api.crafting;

     

    import java.util.ArrayList;

    import java.util.List;

     

    import javax.annotation.Nonnull;

     

    import net.minecraft.entity.item.EntityItem;

    import net.minecraft.inventory.InventoryCrafting;

    import net.minecraft.item.ItemStack;

    import net.minecraft.item.crafting.IRecipe;

    import net.minecraft.world.World;

    import yorkeMC.alfhomancy.common.items.ItemElvenSpirit;

    import yorkeMC.alfhomancy.common.items.ItemWings;

    import yorkeMC.alfhomancy.common.registry.ItemRegistry;

     

    public class ISpiritRecipe implements IRecipe

    {

    @Override

    public boolean matches(InventoryCrafting inv, World w)

    {

    boolean foundSpirit = false;

    boolean foundItem = false;

     

    for (int i = 0; i < inv.getSizeInventory(); i++)

    {

    ItemStack stack = inv.getStackInSlot(i);

     

    if (stack != null)

    {

    if (stack.getItem() == ItemRegistry.ItemElvenSpirit && !foundSpirit) foundSpirit = true;

     

    else if (!foundItem)

    {

    if (stack.getItem() == ItemRegistry.ItemWings) foundItem = true;

    else return false;

    }

    }

    }

    return foundSpirit && foundItem;

    }

     

    @Override

    public ItemStack getCraftingResult(InventoryCrafting inv)

    {

    ItemStack wings = null;

    ItemStack copy = null;

    ItemStack spirit = null;

    List<ItemStack> items = new ArrayList<ItemStack>();

     

    for (int a = 0; a < inv.getSizeInventory(); a++)

    {

    if (inv.getStackInSlot(a) != null)

    {

    items.add(inv.getStackInSlot(a));

    if (items.size() >= 2)

    {

    for (int i = 0; i < items.size(); i++)

    {

    if ((items.get(i)).getItem() == ItemRegistry.ItemWings && items.get(i).getItemDamage() != 0)

    {

    wings = items.get(i);

    copy = wings.copy();

    }

     

    for (int s = 0; s < items.size(); s++)

    {

    if (items.get(s).getItem() == ItemRegistry.ItemElvenSpirit)

    {

    spirit = items.get(s);

    }

     

    for (int go = 0; go < items.size(); go++)

    {

    if ((wings != null && spirit != null))

    {

    if (!ItemWings.hasSpirit(wings, spirit.getItemDamage()))

    {

    ItemWings.addSpirit(copy, spirit.getItemDamage());

    }

    }

    }

    }

    }

    }

    }

    }

    return copy;

    }

     

    @Override

    public int getRecipeSize()

    {

    return 10;

    }

     

    @Override

    public ItemStack getRecipeOutput()

    {

    return null;

    }

    }

     

     

  4. Never mind, solved.

     

    Here is the class if anyone was wondering:

     

     

     

    package yorkeMC.alfheimwings.common.handler;
    
    import java.util.ArrayList;
    
    import net.minecraft.block.Block;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.world.World;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import yorkeMC.alfheimwings.common.Alfheim;
    import yorkeMC.alfheimwings.common.items.ItemWings;
    import yorkeMC.alfheimwings.common.registry.BlockRegistry;
    import yorkeMC.alfheimwings.common.registry.ItemRegistry;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    
    public class SpiritRiteHandler
    {
    @SubscribeEvent
    public void onPlayerInteract(PlayerInteractEvent event)
    {
    	if (event.entity instanceof EntityPlayer)
    	{
    		EntityPlayer p = event.entityPlayer;
    
    		Block centre = event.world.getBlock(event.x, event.y, event.z);
    
    		if (checkRunes(event.world, event.x, event.y + 1, event.z))
    		{
    			ArrayList<EntityItem> items = (ArrayList<EntityItem>) p.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(event.x, event.y, event.z, event.x + 1, event.y + 1, event.z + 1).expand(1D, 1D, 1D));
    
    			if (!p.isSneaking())
    			{
    				if (items.size() >= 2)
    				{
    					for (int i = 0; i < items.size(); i++)
    					{
    						ItemStack wings = null;
    						ItemStack spirit = null;
    
    						if (items.get(i).getEntityItem().getItem() == ItemRegistry.ItemWings)
    						{
    							wings = items.get(i).getEntityItem();
    						}
    
    						for (int s = 0; s < items.size(); s++)
    						{
    							if (items.get(s).getEntityItem().getItem() == ItemRegistry.ItemElvenSpirit)
    							{
    								spirit = items.get(s).getEntityItem();
    							}
    
    							if ((wings != null && wings.getItemDamage() != 0) && spirit != null)
    							{
    								if (!ItemWings.hasSpirit(wings, spirit.getItemDamage()))
    								{
    									ItemWings.addSpirit(wings, spirit.getItemDamage());
    									spirit.stackSize--;
    
    									p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    
    									Alfheim.proxy.spawnShockwaveParticles(event.world, event.x, event.y, event.z);
    									for (int par = 0; par < 200; par++)
    										Alfheim.proxy.wispFX(event.world, event.x - Math.random() + Math.random() * 2, (event.y - 1) + 0.7 + Math.random() * 0.25, event.z - Math.random() + Math.random() * 2, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, (float) -Math.random() * 0.5F, (float) (1.5F + Math.random() * Math.random()));
    								}
    								else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    							}
    							else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    						}
    					}
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    			}
    			else if (p.isSneaking())
    			{
    				if (items.size() == 1)
    				{
    					if (items.get(0).getEntityItem().getItem() == ItemRegistry.ItemWings)
    					{
    						EntityItem entityitem;
    
    						ItemStack wings = items.get(0).getEntityItem();
    
    						if (!p.worldObj.isRemote) removeSpirits(event.world, p, wings, event.x, event.y, event.z);
    
    						if (ItemWings.hasAnySpirit(wings))
    						{
    							Alfheim.proxy.spawnShockwaveParticles(event.world, event.x, event.y, event.z);
    							for (int par = 0; par < 200; par++)
    								Alfheim.proxy.wispFX(event.world, event.x - Math.random() + Math.random() * 2, (event.y - 1) + 0.7 + Math.random() * 0.25, event.z - Math.random() + Math.random() * 2, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, (float) -Math.random() * 0.5F, (float) (1.5F + Math.random() * Math.random()));
    							p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    						}
    					}
    					else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    			}
    		}
    	}
    }
    
    private void removeSpirits(World world, EntityPlayer p, ItemStack wings, double x, double y, double z)
    {
    	EntityItem entityitem;
    
    	for (int sp = 0; sp < 3; sp++)
    	{
    		if (ItemWings.hasSpirit(wings, sp))
    		{
    			ItemWings.removeSpirit(wings, sp);
    
    			entityitem = new EntityItem(world, x - Math.random() + Math.random() * 2, y + Math.random() * 3, z - Math.random() + Math.random() * 2, new ItemStack(ItemRegistry.ItemElvenSpirit, 1, sp));
    
    			world.spawnEntityInWorld(entityitem);
    
    			continue;
    		}
    		else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    	}
    }
    
    public boolean checkRunes(World world, int x, int y, int z)
    {
    	int[][] pos = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 }, { -1, -1 } };
    
    	ArrayList<Boolean> b = new ArrayList<Boolean>();
    
    	for (int i = 0; i < 8; ++i)
    	{
    		if (world.getBlock(x + pos[i][0], y, z + pos[i][1]) == BlockRegistry.BlockSpiritRune) b.add(true);
    		else b.add(false);
    	}
    	if (world.getBlock(x, y, z) == Blocks.air)
    	{
    		b.add(true);
    	}
    	else b.add(false);
    
    	return !b.contains(false);
    }
    }
    

     

     

  5. 1. Download your JAR then run it through this program called BON (I will link the file) to deobfuscate it.

     

    2. Use JD-GUI to open the file, then save all the sources to a .zip folder.

     

    3. Create a directory with forge decompiled in it (extract forge and run in a command window gradlew setupDecompWorkspace, gradlew decompile, and gradlew eclipse).

     

    4. Go to the src/main/java directory and remove the examplemod package, and then remove the mcmod.info from the resources directory.

     

    5. In src/main/java drop your source code from the JD-GUI zip file, and the resources from your JD-GUI zip file.

     

    6. Run from a command window  gradlew setupDecompWorkspace and gradlew eclipse once more.

     

    7. Open it into your eclipse workspace, and continue as normal.

     

    ...

     

    Btw, this has happened to me before.

     

    Link to BON: https://www.dropbox.com/s/z44a8tlf1ujewbc/BON.jar?dl=1

  6. I haven't debugged the runes Boolean. It works fine, the problem isn't weather the runes are found. It is to do with the client and server sides of spawning the entity.

     

    Plus I had to add another check to that Boolean...

     

    public boolean checkRunes(World world, int x, int y, int z)
    {
    	int[][] pos = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 }, { -1, -1 } };
    
    	ArrayList<Boolean> b = new ArrayList<Boolean>();
    
    	for (int i = 0; i < 8; ++i)
    	{
    		if (world.getBlock(x + pos[i][0], y, z + pos[i][1]) == BlockRegistry.BlockSpiritRune) b.add(true);
    		else b.add(false);
    	}
    	if (world.getBlock(x, y, z) == Blocks.air)
    	{
    		b.add(true);
    	}
    	else b.add(false);
    
    	return !b.contains(false);
    }
    

  7. In my main class, in the init method.

     

     

     

    package yorkeMC.alfheimwings.common;
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraftforge.common.MinecraftForge;
    import net.minecraftforge.common.config.Configuration;
    import net.minecraftforge.common.config.Property;
    
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    
    import yorkeMC.alfheimwings.api.AlfheimAPI;
    import yorkeMC.alfheimwings.common.handler.AlfheimEventHandler;
    import yorkeMC.alfheimwings.common.handler.SpiritRiteHandler;
    import yorkeMC.alfheimwings.common.lib.LibCreativeTab;
    import yorkeMC.alfheimwings.common.lib.LibRecipes;
    import yorkeMC.alfheimwings.common.lib.LibStrings;
    import yorkeMC.alfheimwings.common.registry.BlockRegistry;
    import yorkeMC.alfheimwings.common.registry.ItemRegistry;
    import yorkeMC.alfheimwings.common.registry.OreDictionaryRegistry;
    import yorkeMC.alfheimwings.common.registry.WingRegistry;
    import yorkeMC.alfheimwings.common.world.WorldGenOre;
    import cpw.mods.fml.common.FMLCommonHandler;
    import cpw.mods.fml.common.Loader;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.registry.GameRegistry;
    
    @Mod(modid = LibStrings.MODID, name = LibStrings.NAME, version = LibStrings.VERSION, dependencies = LibStrings.DEPENDENCIES)
    public class Alfheim
    {
    // Proxy
    @SidedProxy(clientSide = "yorkeMC.alfheimwings.client.ClientProxy", serverSide = "yorkeMC.alfheimwings.common.CommonProxy")
    public static CommonProxy proxy;
    // Creative Tab
    public static CreativeTabs tabAL = new LibCreativeTab();
    // Config
    public static Configuration config;
    public static int fairyOrePerChunk;
    // Event Handler
    public static AlfheimEventHandler events = new AlfheimEventHandler();
    // Logger
    public static final Logger log = LogManager.getLogger("ALFHEIMWINGS");
    
    /**
     * Loaded mods!
     */
    
    public static boolean thaumcraft = false;
    public static boolean bloodmagic = false;
    public static boolean botania = false;
    public static boolean immersiveengineering = false;
    
    // PREINIT
    @EventHandler
    public static void intro(FMLPreInitializationEvent event)
    {
    	log.info("Pre initializing mod...");
    	log.info("Adding world generator");
    	log.info("Initializing renderers");
    	log.info("Initializing items and blocks");
    	log.info("Initializing recipes");
    	log.info("Registering wings");
    	WingRegistry.init();
    	ItemRegistry.init();
    	BlockRegistry.init();
    	BlockRegistry.initTiles();
    	LibRecipes.init();
    	GameRegistry.registerWorldGenerator(new WorldGenOre(), 0);
    	proxy.initBaubleRenders();
    	proxy.setupClientHandlers();
    	proxy.initParticleRenderers();
    	log.info("There are: " + AlfheimAPI.wingNames.size() + " wing types");
    
    	// CONFIG
    	log.info("Loading config");
    	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    	config.load();
    	Property orePerChunk = config.get("ores", "fairy_ore_per_chunk", ;
    	orePerChunk.comment = "How often Fairy Ore will spawn (approx. veins per chunk)";
    	fairyOrePerChunk = orePerChunk.getInt(;
    
    	log.info("Saving config");
    	config.save();
    
    	thaumcraft = Loader.isModLoaded("Thaumcraft");
    	bloodmagic = Loader.isModLoaded("AWWayofTime");
    	botania = Loader.isModLoaded("Botania");
    	immersiveengineering = Loader.isModLoaded("ImmersiveEngineering");
    }
    
    // INIT
    @EventHandler
    public static void crecendo(FMLInitializationEvent event)
    {
    	log.info("Initializing mod...");
    	log.info("Registering event handlers");
    	MinecraftForge.EVENT_BUS.register(events);
    	FMLCommonHandler.instance().bus().register(events);
    
    	MinecraftForge.EVENT_BUS.register(new SpiritRiteHandler());
    	FMLCommonHandler.instance().bus().register(new SpiritRiteHandler());
    
    	log.info("Registering keybindings");
    	proxy.registerKeyBindings();
    	proxy.setupBlockRenderers();
    }
    
    // POSTINIT
    @EventHandler
    public static void coda(FMLPostInitializationEvent event)
    {
    	log.info("Post initializing mod");
    	log.info("Initializing ore dictionary");
    	OreDictionaryRegistry.init();
    }
    }
    

     

     

  8. So, if there is a circle of runes on the ground and you throw a pair of wings and a spirit into the circle is binds the spirit to the wings. That works fine. (there are visual effects too) then if you shift click with only a pair of wings in the circle and there are spirits already bound to the wings it will remove the spirits from the wings nbt and drop the spirit item in the world. There are different spirits hence different metadata.

  9. So I am trying to spawn an item in the world, but it is not spawning at all.

     

    EventHandler Class

     

     

    package yorkeMC.alfheimwings.common.handler;
    
    import java.util.ArrayList;
    
    import net.minecraft.block.Block;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.world.World;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import yorkeMC.alfheimwings.common.Alfheim;
    import yorkeMC.alfheimwings.common.items.ItemWings;
    import yorkeMC.alfheimwings.common.registry.BlockRegistry;
    import yorkeMC.alfheimwings.common.registry.ItemRegistry;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    import cpw.mods.fml.common.gameevent.TickEvent;
    
    public class SpiritRiteHandler
    {
    @SubscribeEvent
    public void onPlayerInteract(PlayerInteractEvent event)
    {
    	ArrayList<Integer> size = new ArrayList<Integer>();
    
    	if (event.entity instanceof EntityPlayer)
    	{
    		EntityPlayer p = (EntityPlayer) event.entity;
    
    		Block centre = event.world.getBlock(event.x, event.y, event.z);
    
    		if (checkRunes(event.world, event.x, event.y + 1, event.z))
    		{
    			ArrayList<EntityItem> items = (ArrayList<EntityItem>) p.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(event.x, event.y, event.z, event.x + 1, event.y + 1, event.z + 1).expand(1D, 1D, 1D));
    
    			if (!p.isSneaking())
    			{
    				size.add(items.size());
    
    				if (size.get(0) >= 2)
    				{
    					for (int i = 0; i < size.get(0); i++)
    					{
    						ItemStack wings = null;
    						ItemStack spirit = null;
    
    						if (items.get(i).getEntityItem().getItem() == ItemRegistry.ItemWings)
    						{
    							wings = items.get(i).getEntityItem();
    						}
    
    						for (int s = 0; s < size.get(0); s++)
    						{
    							if (items.get(s).getEntityItem().getItem() == ItemRegistry.ItemElvenSpirit)
    							{
    								spirit = items.get(s).getEntityItem();
    							}
    
    							if ((wings != null && wings.getItemDamage() != 0) && spirit != null)
    							{
    								if (!ItemWings.hasSpirit(wings, spirit.getItemDamage()))
    								{
    									ItemWings.addSpirit(wings, spirit.getItemDamage());
    									spirit.stackSize--;
    
    									p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    
    									Alfheim.proxy.spawnShockwaveParticles(event.world, event.x, event.y, event.z);
    									for (int par = 0; par < 200; par++)
    										Alfheim.proxy.wispFX(event.world, event.x - Math.random() + Math.random() * 2, (event.y - 1) + 0.7 + Math.random() * 0.25, event.z - Math.random() + Math.random() * 2, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, (float) -Math.random() * 0.5F, 1.5F);
    								}
    								else if (ItemWings.hasSpirit(wings, spirit.getItemDamage())) p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    							}
    							else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    						}
    					}
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    				size.clear();
    			}
    			else if (p.isSneaking())
    			{
    				if (items.size() == 1)
    				{
    					if (items.get(0).getEntityItem().getItem() == ItemRegistry.ItemWings)
    					{
    						ItemStack wings = items.get(0).getEntityItem();
    
    						for (int sp = 0; sp < 3; sp++)
    						{
    							if (ItemWings.hasSpirit(wings, sp))
    							{
    								ItemWings.removeSpirit(wings, sp);
    
    //Spawn EntityItem in world
    								if (!p.worldObj.isRemote)
    								{
    									EntityItem drop = new EntityItem(event.world, event.x - Math.random() + Math.random() * 2, event.y + Math.random() * 3, event.z - Math.random() + Math.random() * 2, new ItemStack(ItemRegistry.ItemElvenSpirit, 1, sp));
    									p.worldObj.spawnEntityInWorld(drop);
    								}
    								p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    							}
    							else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    						}
    					}
    					else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    			}
    		}
    	}
    }
    
    public boolean checkRunes(World world, int x, int y, int z)
    {
    	int[][] pos = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 }, { -1, -1 } };
    
    	ArrayList<Boolean> b = new ArrayList<Boolean>();
    
    	for (int i = 0; i < 8; ++i)
    	{
    		if (world.getBlock(x + pos[i][0], y, z + pos[i][1]) == BlockRegistry.BlockSpiritRune) b.add(true);
    		else b.add(false);
    	}
    	return !b.contains(false);
    }
    }
    

     

     

     

    EDIT:

     

    Solved. Here is the class if anyone was wondering:

     

     

     

    package yorkeMC.alfheimwings.common.handler;
    
    import java.util.ArrayList;
    
    import net.minecraft.block.Block;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.world.World;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import yorkeMC.alfheimwings.common.Alfheim;
    import yorkeMC.alfheimwings.common.items.ItemWings;
    import yorkeMC.alfheimwings.common.registry.BlockRegistry;
    import yorkeMC.alfheimwings.common.registry.ItemRegistry;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    
    public class SpiritRiteHandler
    {
    @SubscribeEvent
    public void onPlayerInteract(PlayerInteractEvent event)
    {
    	if (event.entity instanceof EntityPlayer)
    	{
    		EntityPlayer p = event.entityPlayer;
    
    		Block centre = event.world.getBlock(event.x, event.y, event.z);
    
    		if (checkRunes(event.world, event.x, event.y + 1, event.z))
    		{
    			ArrayList<EntityItem> items = (ArrayList<EntityItem>) p.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(event.x, event.y, event.z, event.x + 1, event.y + 1, event.z + 1).expand(1D, 1D, 1D));
    
    			if (!p.isSneaking())
    			{
    				if (items.size() >= 2)
    				{
    					for (int i = 0; i < items.size(); i++)
    					{
    						ItemStack wings = null;
    						ItemStack spirit = null;
    
    						if (items.get(i).getEntityItem().getItem() == ItemRegistry.ItemWings)
    						{
    							wings = items.get(i).getEntityItem();
    						}
    
    						for (int s = 0; s < items.size(); s++)
    						{
    							if (items.get(s).getEntityItem().getItem() == ItemRegistry.ItemElvenSpirit)
    							{
    								spirit = items.get(s).getEntityItem();
    							}
    
    							if ((wings != null && wings.getItemDamage() != 0) && spirit != null)
    							{
    								if (!ItemWings.hasSpirit(wings, spirit.getItemDamage()))
    								{
    									ItemWings.addSpirit(wings, spirit.getItemDamage());
    									spirit.stackSize--;
    
    									p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    
    									Alfheim.proxy.spawnShockwaveParticles(event.world, event.x, event.y, event.z);
    									for (int par = 0; par < 200; par++)
    										Alfheim.proxy.wispFX(event.world, event.x - Math.random() + Math.random() * 2, (event.y - 1) + 0.7 + Math.random() * 0.25, event.z - Math.random() + Math.random() * 2, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, (float) -Math.random() * 0.5F, (float) (1.5F + Math.random() * Math.random()));
    								}
    								else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    							}
    							else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    						}
    					}
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    			}
    			else if (p.isSneaking())
    			{
    				if (items.size() == 1)
    				{
    					if (items.get(0).getEntityItem().getItem() == ItemRegistry.ItemWings)
    					{
    						EntityItem entityitem;
    
    						ItemStack wings = items.get(0).getEntityItem();
    
    						if (!p.worldObj.isRemote) removeSpirits(event.world, p, wings, event.x, event.y, event.z);
    
    						if (ItemWings.hasAnySpirit(wings))
    						{
    							Alfheim.proxy.spawnShockwaveParticles(event.world, event.x, event.y, event.z);
    							for (int par = 0; par < 200; par++)
    								Alfheim.proxy.wispFX(event.world, event.x - Math.random() + Math.random() * 2, (event.y - 1) + 0.7 + Math.random() * 0.25, event.z - Math.random() + Math.random() * 2, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.5F, (float) -Math.random() * 0.5F, (float) (1.5F + Math.random() * Math.random()));
    							p.playSound("alfheimwings:craft", 1.0F, 1.0F);
    						}
    					}
    					else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    				}
    				else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    			}
    		}
    	}
    }
    
    private void removeSpirits(World world, EntityPlayer p, ItemStack wings, double x, double y, double z)
    {
    	EntityItem entityitem;
    
    	for (int sp = 0; sp < 3; sp++)
    	{
    		if (ItemWings.hasSpirit(wings, sp))
    		{
    			ItemWings.removeSpirit(wings, sp);
    
    			entityitem = new EntityItem(world, x - Math.random() + Math.random() * 2, y + Math.random() * 3, z - Math.random() + Math.random() * 2, new ItemStack(ItemRegistry.ItemElvenSpirit, 1, sp));
    
    			world.spawnEntityInWorld(entityitem);
    
    			continue;
    		}
    		else p.worldObj.playSoundAtEntity(p, "alfheimwings:fail", 1.0F, 1.0F);
    	}
    }
    
    public boolean checkRunes(World world, int x, int y, int z)
    {
    	int[][] pos = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { -1, 1 }, { 1, -1 }, { -1, -1 } };
    
    	ArrayList<Boolean> b = new ArrayList<Boolean>();
    
    	for (int i = 0; i < 8; ++i)
    	{
    		if (world.getBlock(x + pos[i][0], y, z + pos[i][1]) == BlockRegistry.BlockSpiritRune) b.add(true);
    		else b.add(false);
    	}
    	if (world.getBlock(x, y, z) == Blocks.air)
    	{
    		b.add(true);
    	}
    	else b.add(false);
    
    	return !b.contains(false);
    }
    }
    

     

     

  10. ArrayList#indexOf

    will return -1 if the list doesn't contain the element. Calling

    ArrayList#remove

    with -1 will throw an exception (as you've seen).

     

    You need to figure out why

    bookmarkKeys

    doesn't contain the return value of

    getNotesKey()

    or at least correctly handle the list not containing the element.

     

    I have absolutely no idea why the arraylist is not containing the return for getNotesKey()... I can't find it :L

  11. So, I am using Vazkii's Lexica Botania code (with his permission).

     

    The bookmark feature for some reason crashes when you remove a bookmark, and I cannot figure out why. For some reason it is trying to remove -1 from an array list even when it shouldn't be told to.

     

    Here is the GUI code (modified version of vazkii's, slightly messy ATM)

     

     

    /**

    * This class was created by <Vazkii>. It's distributed as

    * part of the Botania Mod. Get the Source Code in github:

    * https://github.com/Vazkii/Botania

    *

    * Botania is Open Source and distributed under the

    * Botania License: http://botaniamod.net/license.php

    *

    * File Created @ [Jan 14, 2014, 6:48:05 PM (GMT)]

    */

    package yorkeMC.clockwork.client.gui.lexicon;

     

    import java.util.ArrayList;

    import java.util.Collections;

    import java.util.HashMap;

    import java.util.List;

     

    import net.minecraft.client.Minecraft;

    import net.minecraft.client.audio.PositionedSoundRecord;

    import net.minecraft.client.gui.FontRenderer;

    import net.minecraft.client.gui.GuiButton;

    import net.minecraft.client.gui.GuiScreen;

    import net.minecraft.item.ItemStack;

    import net.minecraft.nbt.NBTTagCompound;

    import net.minecraft.util.ChatAllowedCharacters;

    import net.minecraft.util.EnumChatFormatting;

    import net.minecraft.util.ResourceLocation;

    import net.minecraft.util.StatCollector;

     

    import org.lwjgl.input.Keyboard;

    import org.lwjgl.opengl.GL11;

     

    import yorkeMC.clockwork.api.ClockworkAPI;

    import yorkeMC.clockwork.api.lexicon.LexiconCategory;

    import yorkeMC.clockwork.client.gui.lexicon.button.GuiButtonBookmark;

    import yorkeMC.clockwork.client.gui.lexicon.button.GuiButtonCategory;

    import yorkeMC.clockwork.client.gui.lexicon.button.GuiButtonHistory;

    import yorkeMC.clockwork.client.gui.lexicon.button.GuiButtonInvisible;

    import yorkeMC.clockwork.client.gui.lexicon.button.GuiButtonNotes;

    import yorkeMC.clockwork.client.handler.ClientTickHandler;

    import yorkeMC.clockwork.client.handler.PersistentVariableHelper;

    import yorkeMC.clockwork.common.items.ItemLexicon;

    import yorkeMC.clockwork.common.lexicon.page.PageText;

     

    public class GuiLexicon extends GuiScreen

    {

     

    public static GuiLexicon currentOpenLexicon = new GuiLexicon();

    public static ItemStack stackUsed;

     

    public static HashMap<String, String> notes = new HashMap();

     

    private static final String TAG_TYPE = "type";

     

    private static final int[] KONAMI_CODE = { 200, 200, 208, 208, 203, 205, 203, 205, 48, 30 };

     

    public static final int BOOKMARK_START = 1337;

    public static final int NOTES_BUTTON_ID = 1336; // random button tho

    public static final int MAX_BOOKMARK_COUNT = 8;

     

    public static List<GuiLexicon> bookmarks = new ArrayList();

    public static List<String> bookmarkKeys = new ArrayList();

    boolean bookmarksNeedPopulation = false;

     

    public static final ResourceLocation texture = new ResourceLocation("clockwork:textures/gui/gui_lexicon.png");

     

    public float lastTime = 0F;

    public float partialTicks = 0F;

    public float timeDelta = 0F;

     

    int konamiIndex;

     

    private static final int NOTE_TWEEN_TIME = 5;

    public static boolean notesEnabled;

    static int notesMoveTime;

    public String note = "";

    public String categoryHighlight = "";

     

    List<LexiconCategory> allCategories;

     

    String title;

    int guiWidth = 146;

    int guiHeight = 180;

    int left, top;

     

    @Override

    public final void initGui()

    {

    super.initGui();

     

    if (PersistentVariableHelper.firstLoad)

    {

    PersistentVariableHelper.firstLoad = false;

    PersistentVariableHelper.saveSafe();

    }

     

    String key = getNotesKey();

    if (notes.containsKey(key))

    note = notes.get(key);

     

    onInitGui();

    }

     

    public void onInitGui()

    {

    allCategories = new ArrayList(ClockworkAPI.getAllCategories());

    Collections.sort(allCategories);

     

    lastTime = ClientTickHandler.ticksInGame;

     

    title = stackUsed.getDisplayName();

    currentOpenLexicon = this;

     

    left = width / 2 - guiWidth / 2;

    top = height / 2 - guiHeight / 2;

     

    buttonList.clear();

    if (isIndex())

    {

    int x = 18;

    for (int i = 0; i < 12; i++)

    {

    int y = 16 + i * 12;

    buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, ""));

    }

    populateIndex();

    }

    else if (isCategoryIndex())

    {

    int categories = allCategories.size();

    for (int i = 0; i < categories + 1; i++)

    {

    LexiconCategory category = null;

    category = i >= categories ? null : allCategories.get(i);

    int perline = 5;

    int x = i % perline;

    int y = i / perline;

     

    int size = 22;

    GuiButtonCategory button = new GuiButtonCategory(i, left + 18 + x * size, top + 50 + y * size, this, category);

    buttonList.add(button);

    }

    }

    populateBookmarks();

    buttonList.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4));

    }

     

    @Override

    public void updateScreen()

    {

    if (notesEnabled && notesMoveTime < NOTE_TWEEN_TIME)

    notesMoveTime++;

    else if (!notesEnabled && notesMoveTime > 0)

    notesMoveTime--;

    }

     

    @Override

    public void drawScreen(int par1, int par2, float par3)

    {

    float time = ClientTickHandler.ticksInGame + par3;

    timeDelta = time - lastTime;

    lastTime = time;

    partialTicks = par3;

     

    GL11.glColor4f(1F, 1F, 1F, 1F);

    mc.renderEngine.bindTexture(texture);

    drawNotes(par3);

     

    GL11.glColor4f(1F, 1F, 1F, 1F);

    mc.renderEngine.bindTexture(texture);

    drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight);

     

    drawBookmark(left + guiWidth / 2, top - getTitleHeight(), getTitle(), true);

    String subtitle = getSubtitle();

    if (subtitle != null)

    {

    GL11.glScalef(0.5F, 0.5F, 1F);

    drawCenteredString(fontRendererObj, subtitle, left * 2 + guiWidth,

    (top - getTitleHeight() + 11) * 2, 0x00FF00);

    GL11.glScalef(2F, 2F, 1F);

    }

     

    if (isMainPage())

    drawHeader();

     

    if (bookmarksNeedPopulation)

    {

    populateBookmarks();

    bookmarksNeedPopulation = false;

    }

     

    super.drawScreen(par1, par2, par3);

    }

     

    public void drawNotes(float part)

    {

    int size = 105;

     

    float time = notesMoveTime;

    if (notesMoveTime < NOTE_TWEEN_TIME && notesEnabled)

    time += part;

    else if (notesMoveTime > 0 && !notesEnabled)

    time -= part;

     

    int drawSize = (int) (size * time / NOTE_TWEEN_TIME);

    int x = left - drawSize;

    int y = top + 10;

     

    drawTexturedModalRect(x, y, 146, 0, drawSize, 125);

     

    String noteDisplay = note;

    if (notesEnabled && ClientTickHandler.ticksInGame % 20 < 10)

    noteDisplay += "&r_";

     

    fontRendererObj.drawString(

    StatCollector.translateToLocal("lexicon.notes"), x + 5,

    y - 7, 0x666666);

     

    boolean unicode = fontRendererObj.getUnicodeFlag();

    fontRendererObj.setUnicodeFlag(true);

     

    PageText.renderText(x + 5, y - 3, 92, 120, 0, noteDisplay);

    fontRendererObj.setUnicodeFlag(unicode);

    }

     

    public void drawBookmark(int x, int y, String s, boolean drawLeft)

    {

    drawBookmark(x, y, s, drawLeft, 0x111111);

    }

     

    public void drawBookmark(int x, int y, String s, boolean drawLeft, int color)

    {

    // This function is called from the buttons so I can't use fontRendererObj

    FontRenderer font = Minecraft.getMinecraft().fontRenderer;

    boolean unicode = font.getUnicodeFlag();

    font.setUnicodeFlag(true);

    int l = font.getStringWidth(s);

    int fontOff = 0;

     

    if (!drawLeft)

    {

    x += l / 2;

    fontOff = 2;

    }

     

    Minecraft.getMinecraft().renderEngine.bindTexture(texture);

     

    GL11.glColor4f(1F, 1F, 1F, 1F);

    drawTexturedModalRect(x + l / 2 + 3, y - 1, 54, 180, 6, 11);

    if (drawLeft)

    drawTexturedModalRect(x - l / 2 - 9, y - 1, 61, 180, 6, 11);

    for (int i = 0; i < l + 6; i++)

    drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, 180, 1, 11);

     

    font.drawString(s, x - l / 2 + fontOff, y, color, false);

    font.setUnicodeFlag(unicode);

    }

     

    void drawHeader()

    {

    GL11.glPushMatrix();

    GL11.glColor4f(1F, 1F, 1F, 1F);

    Minecraft.getMinecraft().renderEngine.bindTexture(texture);

    drawTexturedModalRect(left - 8, top + 9, 0, 224, 140, 31);

     

    int color = 0xffd200;

    boolean unicode = fontRendererObj.getUnicodeFlag();

    fontRendererObj.drawString(title, left + 6, top + 13, color);

    fontRendererObj.setUnicodeFlag(true);

    fontRendererObj.drawString(String.format(StatCollector.translateToLocal("lexicon.edition"), ItemLexicon.getEdition()), left + 24, top + 22, color);

     

    String s = EnumChatFormatting.BOLD + categoryHighlight;

    fontRendererObj.drawString(s, left + guiWidth / 2 - fontRendererObj.getStringWidth(s) / 2, top + 36, 0);

     

    fontRendererObj.setUnicodeFlag(unicode);

    GL11.glPopMatrix();

     

    categoryHighlight = "";

    }

     

    boolean isMainPage()

    {

    return true;

    }

     

    @Override

    protected void actionPerformed(GuiButton par1GuiButton)

    {

    if(par1GuiButton.id >= BOOKMARK_START)

    {

    if(par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT)

    {

    mc.displayGuiScreen(new GuiLexiconHistory());

    ClientTickHandler.notifyPageChange();

    }

    else handleBookmark(par1GuiButton);

    }

    else if(par1GuiButton instanceof GuiButtonCategory)

    {

    LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory();

     

    mc.displayGuiScreen(new GuiLexiconIndex(category));

    ClientTickHandler.notifyPageChange();

    }

    else switch(par1GuiButton.id)

    {

    case NOTES_BUTTON_ID :

    notesEnabled = !notesEnabled;

    break;

    }

    }

     

    public void handleBookmark(GuiButton par1GuiButton)

    {

    boolean modified = false;

    int i = par1GuiButton.id - BOOKMARK_START;

    String key = getNotesKey();

    if(i == bookmarks.size()) {

    if(!bookmarkKeys.contains(key)) {

    bookmarks.add(this.copy());

    bookmarkKeys.add(key);

    modified = true;

    }

    } else {

    if(isShiftKeyDown()) {

    int index = bookmarkKeys.indexOf(key);

    bookmarks.remove(index);

    bookmarkKeys.remove(index);

     

    modified = true;

    } else {

    GuiLexicon bookmark = bookmarks.get(i).copy();

    if(!bookmark.getTitle().equals(getTitle())) {

    Minecraft.getMinecraft().displayGuiScreen(bookmark);

    if(bookmark instanceof IParented)

    ((IParented) bookmark).setParent(this);

    ClientTickHandler.notifyPageChange();

    }

    }

    }

     

    bookmarksNeedPopulation = true;

    if(modified)

    PersistentVariableHelper.saveSafe();

    }

     

    @Override

    public boolean doesGuiPauseGame()

    {

    return false;

    }

     

    public int bookmarkWidth(String b)

    {

    if (fontRendererObj == null)

    fontRendererObj = Minecraft.getMinecraft().fontRenderer;

     

    boolean unicode = fontRendererObj.getUnicodeFlag();

    fontRendererObj.setUnicodeFlag(true);

    int width = fontRendererObj.getStringWidth(b) + 15;

    fontRendererObj.setUnicodeFlag(unicode);

    return width;

    }

     

    String getTitle()

    {

    return title;

    }

     

    String getSubtitle()

    {

    return null;

    }

     

    int getTitleHeight()

    {

    return getSubtitle() == null ? 12 : 16;

    }

     

    boolean isIndex()

    {

    return false;

    }

     

    boolean isChallenge()

    {

    return false;

    }

     

    boolean isCategoryIndex()

    {

    return true;

    }

     

    void populateIndex()

    {

    List<LexiconCategory> categoryList = ClockworkAPI.getAllCategories();

    int shift = 2;

    for (int i = shift; i < 12; i++)

    {

    int i_ = i - shift;

    GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i);

    LexiconCategory category = i_ >= categoryList.size() ? null

    : categoryList.get(i_);

    if (category != null)

    button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName());

    else

    {

    button.displayString = StatCollector.translateToLocal("lexicon.category.index");

    break;

    }

    }

    }

     

    void populateBookmarks()

    {

    List remove = new ArrayList();

    List<GuiButton> buttons = buttonList;

    for(GuiButton button : buttons)

    if(button.id >= BOOKMARK_START)

    remove.add(button);

    buttonList.removeAll(remove);

     

    int len = bookmarks.size();

    boolean thisExists = false;

    for(GuiLexicon lex : bookmarks)

    if(lex.getTitle().equals(getTitle()))

    thisExists = true;

     

    boolean addEnabled = len < MAX_BOOKMARK_COUNT && this instanceof IParented && !thisExists;

    for(int i = 0; i < len + (addEnabled ? 1 : 0); i++) {

    boolean isAdd = i == bookmarks.size();

    GuiLexicon gui = isAdd ? null : bookmarks.get(i);

    buttonList.add(new GuiButtonBookmark(BOOKMARK_START + i, left + 138, top + 18 + 14 * i, gui == null ? this : gui, gui == null ? "+" : gui.getTitle()));

    }

     

    if(isMainPage())

    buttonList.add(new GuiButtonHistory(BOOKMARK_START + MAX_BOOKMARK_COUNT, left + 138, top + guiHeight - 24, StatCollector.translateToLocal("lexicon.history"), this));

    }

     

    boolean closeScreenOnInvKey()

    {

    return true;

    }

     

    @Override

    protected void keyTyped(char par1, int par2)

    {

    handleNoteKey(par1, par2);

     

    if (!notesEnabled && closeScreenOnInvKey()

    && mc.gameSettings.keyBindInventory.getKeyCode() == par2)

    {

    mc.displayGuiScreen(null);

    mc.setIngameFocus();

    }

     

    if (par2 == KONAMI_CODE[konamiIndex])

    {

    konamiIndex++;

    if (konamiIndex >= KONAMI_CODE.length)

    {

    mc.getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("botania:way")));

    konamiIndex = 0;

    }

    } else

    konamiIndex = 0;

     

    super.keyTyped(par1, par2);

    }

     

    public void handleNoteKey(char par1, int par2)

    {

    if (notesEnabled)

    {

    Keyboard.enableRepeatEvents(true);

    boolean changed = false;

     

    if (par2 == 14 && note.length() > 0)

    {

    if (isCtrlKeyDown())

    note = "";

    else

    {

    if (note.endsWith("<br>"))

    note = note.substring(0, note.length() - 4);

    else

    note = note.substring(0, note.length() - 1);

    }

    changed = true;

    }

     

    if ((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28)

    && note.length() < 250)

    {

    note += par2 == 28 ? "<br>" : par1;

    changed = true;

    }

     

    if (changed)

    {

    notes.put(getNotesKey(), note);

    PersistentVariableHelper.saveSafe();

    }

    } else

    Keyboard.enableRepeatEvents(false);

    }

     

    public static GuiLexicon create(NBTTagCompound cmp)

    {

    String type = cmp.getString(TAG_TYPE);

    try

    {

    GuiLexicon lex = (GuiLexicon) Class.forName(type).newInstance();

    if (lex != null)

    lex.load(cmp);

    if (isValidLexiconGui(lex))

    return lex;

    return null;

    } catch (Exception e)

    {

    e.printStackTrace();

    return null;

    }

    }

     

    public void serialize(NBTTagCompound cmp)

    {

    cmp.setString(TAG_TYPE, getClass().getName());

    }

     

    public String getNotesKey()

    {

    return "index";

    }

     

    public void load(NBTTagCompound cmp)

    {

    // NO-OP

    }

     

    public GuiLexicon copy()

    {

    return new GuiLexicon();

    }

     

    public static boolean isValidLexiconGui(GuiLexicon gui)

    {

    if (gui == null)

    return false;

    if (gui.isCategoryIndex() || gui.isChallenge())

    return true;

    if (gui.isIndex())

    {

    GuiLexiconIndex indexGui = (GuiLexiconIndex) gui;

    if (indexGui.category == null)

    return true;

    return ClockworkAPI.getAllCategories().contains(indexGui.category);

    }

     

    GuiLexiconEntry entryGui = (GuiLexiconEntry) gui;

    if (!ClockworkAPI.getAllEntries().contains(entryGui.entry))

    return false;

     

    return entryGui.page < entryGui.entry.pages.size();

    }

    }

     

     

     

     

    And the crash...

     

     

    crash-2015-11-28_20.15.04-client.txt

     

    ---- Minecraft Crash Report ----

    // I let you down. Sorry :(

     

    Time: 28/11/15 8:15 PM

    Description: Updating screen events

     

    java.lang.ArrayIndexOutOfBoundsException: -1

    at java.util.ArrayList.elementData(Unknown Source)

    at java.util.ArrayList.remove(Unknown Source)

    at yorkeMC.clockwork.client.gui.lexicon.GuiLexicon.handleBookmark(GuiLexicon.java:327)

    at yorkeMC.clockwork.client.gui.lexicon.GuiLexicon.actionPerformed(GuiLexicon.java:296)

    at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:252)

    at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:344)

    at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:313)

    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1732)

    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1040)

    at net.minecraft.client.Minecraft.run(Minecraft.java:962)

    at net.minecraft.client.main.Main.main(Main.java:164)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

    at GradleStart.main(Unknown Source)

     

     

    A detailed walkthrough of the error, its code path and all known details is as follows:

    ---------------------------------------------------------------------------------------

     

    -- Head --

    Stacktrace:

    at java.util.ArrayList.elementData(Unknown Source)

    at java.util.ArrayList.remove(Unknown Source)

    at yorkeMC.clockwork.client.gui.lexicon.GuiLexicon.handleBookmark(GuiLexicon.java:327)

    at yorkeMC.clockwork.client.gui.lexicon.GuiLexicon.actionPerformed(GuiLexicon.java:296)

    at net.minecraft.client.gui.GuiScreen.mouseClicked(GuiScreen.java:252)

    at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:344)

    at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:313)

     

    -- Affected screen --

    Details:

    Screen name: yorkeMC.clockwork.client.gui.lexicon.GuiLexicon

     

    -- Affected level --

    Details:

    Level name: MpServer

    All players: 1 total; [EntityClientPlayerMP['AwesomeBlock2000'/267, l='MpServer', x=-249.33, y=5.62, z=214.72]]

    Chunk stats: MultiplayerChunkCache: 441, 441

    Level seed: 0

    Level generator: ID 01 - flat, ver 0. Features enabled: false

    Level generator options:

    Level spawn location: World: (-296,4,306), Chunk: (at 8,0,2 in -19,19; contains blocks -304,0,304 to -289,255,319), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

    Level time: 129420 game time, 129420 day time

    Level dimension: 0

    Level storage version: 0x00000 - Unknown?

    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

    Forced entities: 88 total; [EntityPig['Pig'/256, l='MpServer', x=-185.22, y=4.00, z=217.16], EntityCow['Cow'/257, l='MpServer', x=-187.81, y=4.00, z=213.09], EntityPig['Pig'/259, l='MpServer', x=-191.09, y=4.00, z=238.03], EntityCow['Cow'/260, l='MpServer', x=-179.22, y=4.00, z=236.97], EntityCow['Cow'/261, l='MpServer', x=-177.25, y=4.00, z=249.69], EntitySlime['Slime'/140, l='MpServer', x=-261.16, y=4.00, z=150.88], EntityClientPlayerMP['AwesomeBlock2000'/267, l='MpServer', x=-249.33, y=5.62, z=214.72], EntityItem['item.item.wheat'/141, l='MpServer', x=-263.31, y=5.13, z=184.19], EntityItem['item.item.seeds'/142, l='MpServer', x=-263.34, y=5.13, z=185.19], EntityItem['item.item.seeds'/143, l='MpServer', x=-262.72, y=5.13, z=183.97], EntityItem['item.item.carrots'/144, l='MpServer', x=-265.88, y=5.13, z=189.03], EntitySlime['Slime'/145, l='MpServer', x=-258.88, y=6.06, z=197.94], EntitySlime['Slime'/146, l='MpServer', x=-261.25, y=5.00, z=198.84], EntityItem['item.item.potato'/147, l='MpServer', x=-269.94, y=5.13, z=195.81], EntityItem['item.item.potato'/148, l='MpServer', x=-271.03, y=5.13, z=194.25], EntitySlime['Slime'/149, l='MpServer', x=-259.31, y=5.81, z=197.06], EntityCreeper['Creeper'/150, l='MpServer', x=-275.93, y=4.00, z=207.05], EntityVillager['Villager'/151, l='MpServer', x=-255.14, y=5.00, z=211.50], EntitySlime['Slime'/152, l='MpServer', x=-267.31, y=6.00, z=222.31], EntityBat['Bat'/153, l='MpServer', x=-256.72, y=7.10, z=218.19], EntityBat['Bat'/154, l='MpServer', x=-229.58, y=7.89, z=216.11], EntitySlime['Slime'/155, l='MpServer', x=-272.69, y=6.00, z=221.88], EntitySlime['Slime'/156, l='MpServer', x=-268.69, y=4.05, z=233.69], EntitySlime['Slime'/157, l='MpServer', x=-265.81, y=6.00, z=224.38], EntitySlime['Slime'/158, l='MpServer', x=-259.31, y=4.00, z=248.69], EntitySlime['Slime'/37166, l='MpServer', x=-280.50, y=4.95, z=265.72], EntitySlime['Slime'/180, l='MpServer', x=-270.00, y=4.00, z=176.72], EntityVillager['Villager'/181, l='MpServer', x=-245.88, y=4.00, z=192.41], EntitySlime['Slime'/182, l='MpServer', x=-251.78, y=4.00, z=200.88], EntityCreeper['Creeper'/183, l='MpServer', x=-241.44, y=9.00, z=196.06], EntityVillager['Villager'/184, l='MpServer', x=-249.75, y=4.00, z=212.28], EntityZombie['Zombie'/185, l='MpServer', x=-251.50, y=3.85, z=228.31], EntitySlime['Slime'/186, l='MpServer', x=-251.22, y=5.00, z=232.22], EntitySlime['Slime'/187, l='MpServer', x=-244.63, y=4.00, z=232.38], EntitySlime['Slime'/188, l='MpServer', x=-249.00, y=5.81, z=232.38], EntitySlime['Slime'/53436, l='MpServer', x=-247.95, y=4.00, z=286.23], EntitySlime['Slime'/189, l='MpServer', x=-247.51, y=6.00, z=236.13], EntitySlime['Slime'/190, l='MpServer', x=-241.78, y=4.00, z=228.22], EntitySlime['Slime'/191, l='MpServer', x=-251.78, y=4.00, z=251.22], EntitySlime['Slime'/53439, l='MpServer', x=-239.22, y=4.00, z=285.16], EntitySlime['Slime'/192, l='MpServer', x=-248.29, y=4.00, z=251.63], EntityBat['Bat'/193, l='MpServer', x=-255.28, y=8.10, z=248.59], EntityItem['item.item.wheat'/194, l='MpServer', x=-242.75, y=5.13, z=263.94], EntityItem['item.item.seeds'/195, l='MpServer', x=-242.56, y=5.13, z=264.34], EntityItem['item.item.wheat'/196, l='MpServer', x=-247.03, y=4.13, z=266.13], EntityItem['item.item.potato'/197, l='MpServer', x=-246.19, y=5.13, z=267.25], EntitySlime['Slime'/198, l='MpServer', x=-255.31, y=4.85, z=256.31], EntitySlime['Slime'/199, l='MpServer', x=-244.30, y=4.18, z=251.63], EntitySlime['Slime'/200, l='MpServer', x=-227.84, y=4.00, z=264.28], EntityPig['Pig'/209, l='MpServer', x=-237.81, y=4.00, z=175.06], EntitySlime['Slime'/210, l='MpServer', x=-228.78, y=4.00, z=205.78], EntitySlime['Slime'/211, l='MpServer', x=-220.03, y=4.61, z=177.07], EntitySlime['Slime'/212, l='MpServer', x=-236.38, y=4.00, z=215.63], EntitySlime['Slime'/213, l='MpServer', x=-228.78, y=5.96, z=217.67], EntitySlime['Slime'/214, l='MpServer', x=-236.38, y=4.96, z=218.91], EntitySlime['Slime'/215, l='MpServer', x=-236.38, y=4.18, z=217.33], EntityPig['Pig'/87, l='MpServer', x=-317.19, y=4.00, z=284.03], EntitySlime['Slime'/216, l='MpServer', x=-234.85, y=4.81, z=216.38], EntitySlime['Slime'/217, l='MpServer', x=-227.65, y=4.47, z=215.85], EntitySlime['Slime'/218, l='MpServer', x=-233.65, y=4.00, z=221.63], EntitySlime['Slime'/219, l='MpServer', x=-226.14, y=4.05, z=216.63], EntityItem['item.item.slimeball'/220, l='MpServer', x=-236.78, y=4.13, z=220.81], EntitySlime['Slime'/221, l='MpServer', x=-235.80, y=4.00, z=222.26], EntitySlime['Slime'/222, l='MpServer', x=-239.70, y=5.00, z=232.69], EntitySlime['Slime'/223, l='MpServer', x=-236.38, y=5.00, z=233.38], EntitySlime['Slime'/224, l='MpServer', x=-233.78, y=5.00, z=232.78], EntitySlime['Slime'/225, l='MpServer', x=-238.83, y=5.00, z=232.69], EntitySlime['Slime'/226, l='MpServer', x=-235.78, y=5.99, z=228.53], EntitySlime['Slime'/227, l='MpServer', x=-227.05, y=4.00, z=226.13], EntityHorse['Donkey'/228, l='MpServer', x=-231.97, y=4.00, z=262.88], EntityChicken['Chicken'/229, l='MpServer', x=-234.31, y=4.00, z=285.66], EntitySlime['Slime'/106, l='MpServer', x=-308.84, y=4.99, z=214.34], EntitySlime['Slime'/236, l='MpServer', x=-233.65, y=4.14, z=167.59], EntitySlime['Slime'/237, l='MpServer', x=-220.66, y=4.00, z=208.69], EntitySlime['Slime'/238, l='MpServer', x=-217.61, y=4.00, z=208.38], EntitySlime['Slime'/239, l='MpServer', x=-212.75, y=4.00, z=200.90], EntitySlime['Slime'/240, l='MpServer', x=-211.06, y=4.00, z=210.31], EntitySlime['Slime'/241, l='MpServer', x=-219.43, y=4.00, z=208.36], EntitySlime['Slime'/242, l='MpServer', x=-195.94, y=4.00, z=225.75], EntityHorse['Donkey'/243, l='MpServer', x=-212.72, y=4.00, z=273.88], EntitySlime['Slime'/116, l='MpServer', x=-272.31, y=4.00, z=233.69], EntitySlime['Slime'/117, l='MpServer', x=-273.66, y=5.85, z=226.50], EntitySlime['Slime'/118, l='MpServer', x=-278.13, y=6.00, z=271.31], EntitySlime['Slime'/119, l='MpServer', x=-276.69, y=6.00, z=269.88], EntityCow['Cow'/248, l='MpServer', x=-190.19, y=4.00, z=235.81], EntitySlime['Slime'/120, l='MpServer', x=-270.59, y=5.00, z=277.97], EntitySlime['Slime'/249, l='MpServer', x=-189.02, y=4.00, z=288.24], EntitySlime['Slime'/250, l='MpServer', x=-200.89, y=4.00, z=284.35]]

    Retry entities: 0 total; []

    Server brand: fml,forge

    Server type: Integrated singleplayer server

    Stacktrace:

    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)

    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2567)

    at net.minecraft.client.Minecraft.run(Minecraft.java:983)

    at net.minecraft.client.main.Main.main(Main.java:164)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

    at GradleStart.main(Unknown Source)

     

    -- System Details --

    Details:

    Minecraft Version: 1.7.10

    Operating System: Windows 10 (amd64) version 10.0

    Java Version: 1.8.0_60, Oracle Corporation

    Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

    Memory: 694474048 bytes (662 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active

    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

    UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)

    UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

    UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)

    UCHIJAAAA ClockworkTinkering{0.0} [Clockwork Tinkering] (bin)

    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 354.35' Renderer: 'GeForce GTX 860M/PCIe/SSE2'

    Launched Version: 1.7.10

    LWJGL: 2.9.1

    OpenGL: GeForce GTX 860M/PCIe/SSE2 GL version 4.5.0 NVIDIA 354.35, NVIDIA Corporation

    GL Caps: Using GL 1.3 multitexturing.

    Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

    Anisotropic filtering is supported and maximum anisotropy is 16.

    Shaders are available because OpenGL 2.1 is supported.

     

    Is Modded: Definitely; Client brand changed to 'fml,forge'

    Type: Client (map_client.txt)

    Resource Packs: []

    Current Language: English (US)

    Profiler Position: N/A (disabled)

    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

    Anisotropic Filtering: Off (1)

     

     

  12. I want to include the source (or SDK) for the use of RF in my mod (Similar to other mods and cross mod compatibility)

    In other words, I want to make my machines compatible with COFH's RF Energy.

     

    How would I go about doing this?

     

    I have tried already downloading cofhlib and I can't import it into my project, It says that there is no source linked, and as I can

    Imagine, this is because the files are already compiled. (I even went to project settings and added it as an external JAR. No avail.)

     

    Refer to my post in your last thread. I accidentally replied there.

  13. Ok Understood.

     

    Last Question, Not related though...

     

    I want to include the source (or SDK) for the use of RF in my mod (Similar to other mods and cross mod compatibility)

    In other words, I want to make my machines compatible with COFH's RF Energy.

     

    How would I go about doing this?

     

    It is quite easy actually, and you don't need to include the source of COFH's RF in your mod. I do this with Thaumcraft (I write the TC addon Tainted Magic).

     

    Basically, in short, you need to add a deobfuscated version COFH's lib as a referenced library. You do this by first downloading a deobf / dev version, then going into your build path - assuming you're in eclipse - and adding it as a referenced library from an external jar. Add this jar to a folder in your modding folder called libs so it builds properly. If you need more help DM me on twitter.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.