Results 1 to 12 of 12
  1. #1
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Question Get all components in list and every time it finds one add ||

    I need to finish writing one Hook for API.
    I need to get list of ints and add them to this:
    Java Code:
    if (var5 == Block.stairSingle.blockID || var5 == Block.tilledField.blockID || var5 == Block.stairCompactCobblestone.blockID || var5 == Block.stairCompactPlanks.blockID)
    {
    }
    I will post some more lines of my code.

    The list:
    Java Code:
    public class ForgeHooksClient
    {
        public static LinkedList blocksToLightProperly = new LinkedList();
    }
    The adding code to the list:
    (I wanna check if blockID is null. If it is, then not to add to list.)
    Java Code:
    public class MinecraftForgeClient
    {
        /**
          * Adds Half-Steps or Stairs to have properly rendered lighting.
          *@param block Block to render properly.
          */
        public static void addHalfStepOrStairLightingRendering(int blockID)
        {
        	try
        	{
        		ForgeHooksClient.blocksToLightProperly.add(blockID);
        	}
        	catch (Exception e)
        	{
        		e.printStackTrace();
        		return;
        	}
        }
    }
    So basically I need to add all things from blocksToLightProperly list to the line of code I posted up there.
    Another thing is I need to add || every time I add another int from blocksToLightProperly list.

    Heres my current code of that line, what gives errors:
    (I didnt even try to fix those, cause I know I wouldnt been able to.)
    Java Code:
    if (var5 == Block.stairSingle.blockID || var5 == Block.tilledField.blockID || var5 == Block.stairCompactCobblestone.blockID || var5 == Block.stairCompactPlanks.blockID || var5 == ForgeHooksClient.blocksToLightProperly)
    I hope someone can help me.
    Also I have never gone to Java School, I have learnt on my own, if it is something really simple please dont be angry at me.
    Also Im not greatest at English.

    EDIT:
    I use Eclipse to code.
    Last edited by tambry; 07-04-2012 at 10:34 AM. Reason: Added what editor I use and added some Bold text.

  2. #2
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Re: Get all components in list and every time it finds one add ||

    help, please?

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,310
    Blog Entries
    7
    Rep Power
    20

    Default Re: Get all components in list and every time it finds one add ||

    I don't understand what you mean by "I need to add ||".

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Post Re: Get all components in list and every time it finds one add ||

    Quote Originally Posted by JosAH View Post
    I don't understand what you mean by "I need to add ||".

    kind regards,

    Jos
    || = or
    Every time it adds one and goes forward I need to add there "or" aka "||" so it goes forward, other ways it will be like: "Why theres no ||? Just lets throw an exception!".
    Last edited by tambry; 07-04-2012 at 06:54 PM.

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,757
    Rep Power
    19

    Default Re: Get all components in list and every time it finds one add ||

    Aren't there minecraft forums?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Re: Get all components in list and every time it finds one add ||

    Quote Originally Posted by Tolls View Post
    Aren't there minecraft forums?
    They only have sections for modding that wouldnt fit in, first they would scream it isnt for modding helping, its mostly for errors so people can help out other people, but I dont have and error, I need help with programming, and code isnt related enough to Minecraft that I could ask there. People here should understand what I want cause
    Java Code:
    if (program.int)
    {
        return;
    }
    or
    Java Code:
    LinkedList someInts = new LinkedList();
    Arent really related to Minecraft.
    This is for one of Minecraft API's called Minecraft Forge.
    Last edited by tambry; 07-04-2012 at 07:38 PM.

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,757
    Rep Power
    19

    Default Re: Get all components in list and every time it finds one add ||

    I know it's not Minecraft as such, but I was wondering if this was the sort of thing that had been done before.
    There's a large modding community, so I would have expected there to be examples you could borrow from. The problem I have is I don;t actually understand what you are trying to do, so it's hard to come up with an answer.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  8. #8
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Re: Get all components in list and every time it finds one add ||

    Quote Originally Posted by Tolls View Post
    I know it's not Minecraft as such, but I was wondering if this was the sort of thing that had been done before.
    There's a large modding community, so I would have expected there to be examples you could borrow from. The problem I have is I don;t actually understand what you are trying to do, so it's hard to come up with an answer.
    No examples, I have to add all things in the list to the if () thing, I dont need all other things from
    Java Code:
    if (var5 == Block.stairSingle.blockID || var5 == Block.tilledField.blockID || var5 == Block.stairCompactCobblestone.blockID || var5 == Block.stairCompactPlanks.blockID)
    {
    }
    The MinecraftForgeClient has intialization so I can add those there.
    If I could use:
    Java Code:
    if (var5 == ForgeHooksClient.blocksToLightProperly.hashCode())
    {
    }
    Would that add all things from blockToLightProperly LinkedList to the var5, and it has to check "or" aka "||"?

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,757
    Rep Power
    19

    Default Re: Get all components in list and every time it finds one add ||

    OK, so let me try and turn this into a requirement.
    You want to do something if 'var5' is one of several things, which are not static.
    So if 'var5' is in a List of things.

    So, create a Set<Integer> and add all the things you need to check to that Set.
    Then 'if (yourSet.contains(var5))'.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Re: Get all components in list and every time it finds one add ||

    My Set always returns null now.
    Java Code:
    public static Set<Integer> blocksToLightProperly;
    It needs to equal something...
    Java Code:
    public static Set<Integer> blocksToLightProperly = new Set<Integer>;
    That doesnt work. (It will give a error)
    I dont really know what should it equal...

    (Sry for late answer, I was on vacation for sometime)

  11. #11
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,757
    Rep Power
    19

    Default Re: Get all components in list and every time it finds one add ||

    You need to learn Java.
    Here's the API for Set.
    It is an interface, so you need a proper class that implements Set, which that page lists.
    HashSet is the most likely one for you to use.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    tambry is offline Member
    Join Date
    Jul 2012
    Posts
    7
    Rep Power
    0

    Default Re: Get all components in list and every time it finds one add ||

    Quote Originally Posted by Tolls View Post
    You need to learn Java.
    Here's the API for Set.
    It is an interface, so you need a proper class that implements Set, which that page lists.
    HashSet is the most likely one for you to use.
    Thank you really much for help, it works now!

Similar Threads

  1. Replies: 0
    Last Post: 12-02-2011, 09:03 AM
  2. Replies: 3
    Last Post: 08-23-2011, 12:46 PM
  3. Linked List, Array List time complexity
    By Rick99771977 in forum New To Java
    Replies: 4
    Last Post: 08-18-2011, 05:37 AM
  4. Finds resource in netbeans but the jar does not
    By dko in forum Advanced Java
    Replies: 13
    Last Post: 05-28-2011, 02:58 AM
  5. Different components in an AWT list
    By alinaqvi90 in forum AWT / Swing
    Replies: 10
    Last Post: 08-13-2010, 10:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •