Jump to content

Recommended Posts

Posted

Ok first question I have today is this. Basically I have a Block with subblocks, you know, with metadata. And everything seems fine, except for some reason the unlocalized name of them don't seem to be registering, the textures seem to work fine aswell. I also find that the localized name is always tile.[Nameofblockgroup].name. I am using an enum file containing block names and certain variables to simplify for future plans btw.

 

Now, my second question may be a bit of a long shot of a question.... Is it at all possible to create subblocks of crops, each with their own texture, drops, max growth, etc. Based on what I have done, it seems possible to do, but I am unsure.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

For the unlocalized name: you need a custom ItemBlock. Have a look at this. For the crops, I think you can, but keep in mind that a block can only have 16 variants. And some of that might be easier in 1.8 with BlockStates.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • 1 month later...
Posted

Ok, now that I have got this settled for now. I have a new question, is it possible to make an item that can look for item/s that are on top of a block it right clicks on, make those item/s instantly despawn, and replace the detected item/s with another item/s? For example, if I drop 3 redstone, and 1 stick on any block and right click it with my item it will "consume" the items on that block and create the item I set it to. I'd assume this is possible, but not completely sure.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Such a thing is perfectly possible!

 

Here are your ingredients:

Anywhere you are given a World as a parameter, you can call getEntitesWithinAABB(Class passedClass, AxisAlignedBB passedAABB), which will return an ArrayList of entities of the passed class type within the passed bounding box.

Dropped items are objects of type EntityItem; and EntityItems have a method called getEntityItem which returns the ItemStack they "contain".

Posted

So, how would I utilize getEntitesWithinAABB within the onItemUse method for what I want it to do?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

  • 2 weeks later...
Posted

Ok, so I have tried to use the getEntitiesWithinAABB within the onItemUse method, and I can't seem to get it to work :(

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

To be specific, I can't seem to get my item to check above of the block it is used on for 4 redstone item, 2 glowstone dusts, and 1 stick. Aswell as remove only those "amount" items from the world and spawn a certain item in their place.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Hi

 

Since I'm a newbie, forgive if I don't know everything correctly.

 

What I'v learned so far, you need to do something like the following:

1. Get the EntityItem within a certain radius (MrCaracal gave you the ingredients)

2. Iterate through the result to check if

    a) the item's are correct

    b) the amount of each item is correct.

 

I mostly learn forge through examples, so here is one:

 

  Reveal hidden contents

 

 

I hope that was helpful

Sincerely -pick

 

PS: It really IS helpful to post the 'not working' code...

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

Thanks to you both, I have made good progress, except when I put a stack of the item it searches for down it only drops the number of set item when there is only one.... Also I would like to make it do different things when it detect different numbers. For instance when atleast 5 redstone, 2 glowstone, and 1 stick are detected it will only remove those set numbers of items from the area, and spawn the correct itemstack. Here is my current onItemUse method:

 

  Reveal hidden contents

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

G'Day

 

  On 12/26/2014 at 6:20 PM, Electrobob99 said:

Thanks to you both, I have made good progress, except when I put a stack of the item it searches for down it only drops the number of set item when there is only one.... Also I would like to make it do different things when it detect different numbers. For instance when atleast 5 redstone, 2 glowstone, and 1 stick are detected it will only remove those set numbers of items from the area, and spawn the correct itemstack.

Wow, that's a weird sentence. Let's check if I got you right:

 

- You want to remove the 'consumed' amount from a ItemStack

- You'd like to craft the result several times, if enough items are provided?

 

If that is _not_ your target, I suggest to rewrite your question.

Otherwise:

 

Your code is a kind of strict and mercyless, isn't it? You check for the desired item and if it is, you just remove the complete EntityItem,

regardless to stackSize or anything else.

 

If I had to do something like your target, I'd create my own recipes class and code

a manager for those recipes. This manager may receives an ArrayList of EntityItems and

all the magic would happen there. It would be responsible for only taking the

desired amount of items, the spawning of the new one etc

 

The point you missed in your previous code example is,

that you need to check the _stackSize_ of the ItemStack.

Something like:

 

  Reveal hidden contents

 

The above code would go into said manager or into the iteration through the list of EntityItems.

 

I haven't covered yet that you also want to check several items. I would have for each

amount / item tuple a boolean flag. Instead of crafting the result during

the iteration, I'd then check _after_ the iteration if all the flags are true.

 

I hope this reply is helpful (sorry, it's kinda long)

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

From what I can see, you got what I meant with my question. If this does want I need, I may try to get a recipe class made for this, which to be honest, I haven't done that before :)

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok, so it does work :) Now few questions now.

1)How do I code a recipemanager for this?

2)How would I code it for multiple "ingredients"?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Before you initialize your EntityItem variable, you should probably check if the entity on top of the block IS an Item. If it's not your game will crash. As for the recipe manager, look into the CraftingManager class. Maybe you could use ArrayLists and a getter or something. I'm not sure exactly, but I'd have to look.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted
  On 12/27/2014 at 1:48 AM, Asweez said:

Before you initialize your EntityItem variable, you should probably check if the entity on top of the block IS an Item. If it's not your game will crash.

Ok, I have tested and it doesn't seem to crash with any other entity, unless I'm missing one. And hasn't crashed yet.... Currently trying to build and implement the recipe manager for this type of function, hopefully with the possibilities for extra "ingredients" to search for.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok, so I honestly haven't been making any leeway on even starting a custom manager for this concept :( Can someone point me in the proper direction, aside from just copying and pasting the CraftingManager class and editing it?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Dear Electrobob99

 

I'd like to help and I am still a newbie in forge, but I do code in java for a longer time now.

The said 'CraftingManager' that I mentioned previously is what you have to come up with.

From my point of view, the vanilla craftingmanager doesn't fit to the requirements.

 

More than this, I think this is the part where your creativity gets involved:

 

Having an idea and convert it to actual code is not teachable.

 

I'd suggest to write down (on good old paper) what you need and then construct your classes. May there is already something out there, that fits in what you are looking for.

 

To still give some reply on your last question:

Firstly you need an abstraction of such an recipe: Store the tuple ingredient/amount/result in it and may some other information. As a next step, I'd suggest to code some sort of CraftingManager that is capable of holding such recipes. It should also have some power, meaning that it's able to sort these recipes (Comperable recipes or a Comperator).

 

Since this is not my project, I don't know wheter I covered all the points...

 

May this post was helpful, but I'd really recommed in tinkering around or get another person on board.

 

Sincerely -pick

 

 

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

I really don't understand what you are saying to be honest. From what I understand, I should write it in pseudo-code on good old paper and then code it. I've done that. But I don't know how to code it...

I know my handler needs to be able to take in the entity items that are around the item's rightclicked area, take those items and compare them with needed items within stock recipes, then if they match check if all needed items for one creation are there, and if they are create said items....

And that's basically what I had written down for weeks.... But question is how do I code it?

 

I don't understand Pseudo-code at all :(

 

 

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Hello again

 

Well, what I've tried to say is, that you need your creativity to answer this question. Or another developer.

 

It's slightly difficult to explain this process of 'having an idea and get into code'. I personally absolutely don't like pseudo-code, I'd rather work with some sequenz diagrams or mostly better with a mix of UML class diagrams, 'ability list' and some sort of crazy sketches of the object's behaviour that no-one but me can read.

 

I cannot tell you more about this than I've done yet. Learn more Java or break down your goal into smaller pieces and achieve them step by step.

 

I don't support copy-paste replies on questions, but this time I've made an exception, I guess.

Since I replied a lot in this thread I made some further thoughts on the given problem. In the next spoilers I will post some code that I made but please keep in mind:

 

- This code is anything but near completion

- It's made quickly and not tested into depth

- Not able of the desired 'craft as many times as possible'

- Very basic

- Do whatever you want with it

 

May it helps you. I haven't commented much, so feel free to ask if something is not 'self-explaining'.

 

First the recipe class

 

  Reveal hidden contents

 

 

Secondly the manager class:

 

  Reveal hidden contents

 

 

And lastly an example-testing item:

 

  Reveal hidden contents

 

 

May you got me this time...

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

Ok this makes sense now... But one question remains. Do I have to have the crafting manager initialized somewhere? I ask this because no matter what I adjust it doesn't seem to do anything with rightclick, doesn't even get to System.out.println("no items found"); when no items are in the list.

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Ok, found out a possible reason why it's not working... It seems that the method: craftInWorld is empty inside of the manager class. Guess I will just have to think and put the proper info inside that method to get the full file to do it's job xD

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

From what I can see the craftInWorld method needs to send the list of itemstacks it receives from the item used to the craft method, etc. Currently it works for a short time, but crashes when no items are around the item's right click. The following is what I currently have in the manager, where I used print statements for debugging:

 

  Reveal hidden contents

 

Can someone tell me what I may be missing?

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

Posted

Hi

 

Well, the point is that you don't check if there ARE items or not. It's written so, that if no recipe was found (which is the case if no ingredients are available), the recipe is null. If you try to craft the result of null, it will throw a NullPointerException.

 

Be patient, I think I can come up with another solution shortly.

 

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Posted

Dear Electrobob99

 

I spend another few moments on your problem and since since other modders could be interested as well, I'd like to share my code with you.

 

Although I versioned the files with version 1.0, I guess these mechanique could be improved alot.

Read the javadoc breifly and you should understand what I've done.

 

Please keep in mind, that I wrote this quickly and did only made the following tests:

I used the _InWorldCrafter_ item to test the manager and recipes, in this item I also added the recipes - that's not how to use it in a real environment!

The given recipes are processed correctly and beyond that I don't know (as often in programming: 'it should work...').

 

I'm absolutely not keen on fame but if any of you take these lines, please leave a notice from where this code comes from.

 

The recipe class:

 

  Reveal hidden contents

 

 

The manager class:

 

  Reveal hidden contents

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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