Jump to content

Recommended Posts

Posted

Hey there, I was wondering if it is possible for onNeighbourBlock to detect the oreDict of whatever is next to it?

For example:

 public void onNeighborBlockChange(World world, int posX, int posY, int posZ, Block neighbourBlock){
	 if (world.getBlock(posX, posY + 1, posZ) == Blocks.iron_ore){

but I wanted it to be the ore dictionary for iron ore, because that would make some amount of sense for what this does would it be possible to do that?

Why bother?

Posted

Sure. First, get the oreID for ironOre, or whatever you want to check for. Then do Ints.containts(OreDicitionary.getOreIDs(<stack>), <ironOreID>).

When you say stack? Do you mean it'd be something like:

Ints.containts(OreDicitionary.getOreIDs(1), ore:oreIron)

to do 1 iron ore?

Why bother?

Posted

Wat.

 

1) OreDicitionary.getOreIDs(...) requires an ItemStack passed to it.  1 is an integer.

2) ore:oreIron, even if you declared that as a string (which you didn't, so it'll just throw all kinds of errors), that's not the oreDict string for iron ore.

3) Even if it was the correct string, it's not an integer!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Wat.

 

1) OreDicitionary.getOreIDs(...) requires an ItemStack passed to it.  1 is an integer.

2) ore:oreIron, even if you declared that as a string (which you didn't, so it'll just throw all kinds of errors), that's not the oreDict string for iron ore.

3) Even if it was the correct string, it's not an integer!

 

My bad, I saw stack as a "how many you would want" (I was replying while on my way home from work, so I didn't know what it needed...

So let me correct that now...

So I have:

if (world.getBlock(posX, posY + 1, posZ) == OreDictionary.getOreIDs(, "ore:oreIron")
[code]
But I don't actually understand what it wants in the brackets, it suggests null (when you add unimplemented methods) but that breaks everything... I really don't know what to put in there  (Sorry for the newbie questions, but I have never used oreDict, and the code
[code]
    public static int[] getOreIDs(ItemStack stack)
    {
        if (stack == null || stack.getItem() == null) return new int[0];

        Set<Integer> set = new HashSet<Integer>();

        int id = Item.getIdFromItem(stack.getItem());
        List<Integer> ids = stackToId.get(id);
        if (ids != null) set.addAll(ids);
        ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
        if (ids != null) set.addAll(ids);

        Integer[] tmp = set.toArray(new Integer[set.size()]);
        int[] ret = new int[tmp.length];
        for (int x = 0; x < tmp.length; x++)
            ret[x] = tmp[x];
        return ret;
    }

doesn't really make sense :/

 

 

 

 

And i didn't do 

Ints.containts(OreDicitionary.getOreIDs(<stack>), <ironOreID>)

because the

Ints.containts

didn't exist (dunno if that is needed or not)

Why bother?

Posted

That is not even close. If anything, you got FATHER away. Now your trying to compare a Block with an int[]

 

Oh, and "ore:oreIron" is still wrong.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That is not even close. If anything, you got FATHER away. Now your trying to compare a Block with an int[]

 

Oh, and "ore:oreIron" is still wrong.

From ore dictionary class... do I just need to do oreIron?

            registerOre("oreIron",    Blocks.iron_ore);

 

So this?

Ints.contains(OreDictionary.getOreIDs(null), "oreIron")

Which still shows errors, I don't know what that Ints is supposed to be, and the null? I don't understand what it should be...

Why bother?

Posted

Seriously?

 

/**

    * Gets all the integer ID for the ores that the specified item stakc is registered to.

    * If the item stack is not linked to any ore, this will return an empty array and no new entry will be created.

    *

    * @param stack The item stack of the ore.

    * @return An array of ids that this ore is registerd as.

    */

 

And "oreIron" is still not an integer.  You need

getOreID(String name)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Seriously?

 

/**

    * Gets all the integer ID for the ores that the specified item stakc is registered to.

    * If the item stack is not linked to any ore, this will return an empty array and no new entry will be created.

    *

    * @param stack The item stack of the ore.

    * @return An array of ids that this ore is registerd as.

    */

 

And "oreIron" is still not an integer.  You need

getOreID(String name)

 

Yes, call me an idiot all you like, but I don't know what that means!

Getting somewhere though through my idiocy and I apologize for this:

 public void onNeighborBlockChange(World world, int posX, int posY, int posZ, Block neighbourBlock){
	 if (world.getBlock(posX, posY + 1, posZ) == Ints.contains(OreDictionary.getOreIDs((neighbourBlock),getOreID("oreIron"))

now the only issue is the getOreID... well... it doesn't work?

Why bother?

Posted

You don't know what an ItemStack is or how to use it? o..O

 

now the only issue is the getOreID

 

OreDictionary.getOreID(...)

 

I thought that was pretty obvious.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You don't know what an ItemStack is or how to use it? o..O

 

now the only issue is the getOreID

 

OreDictionary.getOreID(...)

 

I thought that was pretty obvious.

 

public void onNeighborBlockChange(World world, int posX, int posY, int posZ, Block neighbourBlock){

if (world.getBlock(posX, posY + 1, posZ) == Ints.contains(OreDictionary.getOreID("oreIron"){

 

Still getting issues though...

Ints is erroring, but I don't know what to do with it, as importing the only option doesn't fix anything :/

Why bother?

Posted

And then you dropped

OreDictionary.getOreIDs(neighbourBlock)

for no apparent reason.

 

And you're comparing a Block to a boolean.

 

And

Ints

is not an object or a class.

 

And you're missing a )

 

It's like you're doing stuff without thinking about what that stuff you're doing means.  You're back to a point where you don't even have "code that makes sense, but contains syntax errors."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

And then you dropped

OreDictionary.getOreIDs(neighbourBlock)

for no apparent reason.

 

And you're comparing a Block to a boolean.

 

And

Ints

is not an object or a class.

 

And you're missing a )

 

It's like you're doing stuff without thinking about what that stuff you're doing means.  You're back to a point where you don't even have "code that makes sense, but contains syntax errors."

I dropped it because this didn't work:

public void onNeighborBlockChange(World world, int posX, int posY, int posZ, Block neighbourBlock){

if (world.getBlock(posX, posY + 1, posZ) == contains(OreDictionary.getOreIDs((neighbourBlock),OreDictionary.getOreID("oreIron")))){

 

And I thought you meant use the other... the issue is "getOreIDs" it says it's not applicable for Block, int

Why bother?

Posted

it says it's not applicable for Block, int

If you don't know what this means then you need to go do some tutorials about basic Java.

I know what it means. But I don't understand why, I was told to do that, but then find out it doesn't work...

Why bother?

Posted

I know what it means. But I don't understand why, I was told to do that, but then find out it doesn't work...

 

Because you're not doing it right and no one is just going to write your code for you.

 

You need to understand the functions involved and put the puzzle pieces together yourself.

 

I'm done helping you.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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