Sign in to follow this  
LifesaverM

Item Creation

Recommended Posts

So I'm making progress and pretty decent at changing something to do or be something else. I know kinda vague, but I've always excelled at debugging others work or taking existing code and manipulating it to do something else I want. If it wasn't for the fact that after 20 years I'm back in college again getting my Master's degree I would take the time to take online classes to learn Java better. As I've mentioned most of my coding over the years has been finding issues with others work or changing existing code to do what I want. I've done some various scripting as well (ex. Lua for SecondLife) though by no means an expert.

 

I'm at a place now where I want to add some new items, and eventually figure out how to make them craftable in world and establish their construction parameters. But first thing is first creating and inserting the new item and its template fields into the code for use. I so wish the items where in a database I'd have this done easy peasy.

 

I've been looking at the various Item classes, template, and factory for spitting things out once the item exists. I'm a little lost in figuring out how to make this (add new item) happen. Like if this was just a matter of copying a section of code and change all the item's property fields and assigning it a unique item template # I'd be fine.

 

Any suggestions or tips would be appreciated. (Then my next step would be figuring out how to do this via the modloader so I don't have to edit code every patch but baby steps, baby steps).

 

My interests right now is custom content creation then maybe other things down the road. Models, textures, mappings no problem, just need to figure out how to create the item(s) so the new models can come to life.

Edited by LifesaverM

Share this post


Link to post
Share on other sites

 

.... One way is to use Ago's modloader. you need to implement the ItemTemplatesCreatedListener and ServerStartedListener. You can look at the following as it has some useful information. I'd say the the classes that have "Action" on the end are most useful. I made it to operate on an area instead of a single tile so it does have some complicated array related code. But hopefully you can see the basic pattern: make items, add creation entries, add action/behaviors to use the new items in different ways.

https://github.com/Joedobo27/FarmBarrelMod/tree/master/src/main/java/com/joedobo27/farmbarrelmod

 

I frequently use the ItemTemplateBuilder to make items, use the CreationEntryCreator to add new crafting options (there're two, one for simple item+target and another for advanced where you do continue actions to finish it) and finally use the actionPerformer/behaviorProvider to add custom function for those new items.

@Override
public void onItemTemplatesCreated() {
	ItemTemplateBuilder sowBarrel = new ItemTemplateBuilder("jdbSowBarrel");
	sowBarrelTemplateId = IdFactory.getIdFor("jdbSowBarrel", IdType.ITEMTEMPLATE);
	sowBarrel.name("Seed barrel","seed barrels", "A tool used to sow seed over an area.");
	sowBarrel.size(3);
	//sowBarrel.descriptions();
	sowBarrel.itemTypes(new short[]{ItemTypes.ITEM_TYPE_WOOD, ItemTypes.ITEM_TYPE_NAMED, ItemTypes.ITEM_TYPE_REPAIRABLE,
			ItemTypes.ITEM_TYPE_COLORABLE, ItemTypes.ITEM_TYPE_HASDATA});
	sowBarrel.imageNumber((short) 245);
	sowBarrel.behaviourType((short) 1);
	sowBarrel.combatDamage(0);
	sowBarrel.decayTime(2419200L);
	sowBarrel.dimensions(30, 30, 50);
	sowBarrel.primarySkill(-10);
	//sowBarrel.bodySpaces();
	sowBarrel.modelName("model.container.barrel.small.");
	sowBarrel.difficulty(5);
	sowBarrel.weightGrams(1000);
	sowBarrel.material((byte) 14);
	sowBarrel.value(10000);
	sowBarrel.isTraded(true);
	//sowBarrel.armourType();
	try {
		sowBarrel.build();
	} catch (IOException e){
		logger.log(Level.WARNING, e.getMessage(), e);
	}
}

....

@Override
public void onServerStarted() {
	AdvancedCreationEntry sowBarrel = CreationEntryCreator.createAdvancedEntry(SkillList.CARPENTRY,
			ItemList.plank, ItemList.pegWood, sowBarrelTemplateId, false, false, 0.0f, true, false,
			CreationCategories.TOOLS);
	sowBarrel.addRequirement(new CreationRequirement(1, ItemList.plank, 4, true));
	sowBarrel.addRequirement(new CreationRequirement(2, ItemList.pegWood, 4, true));
	sowBarrel.addRequirement(new CreationRequirement(3, ItemList.rope, 1, true));
}

...

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Joe I also looked at some stuff Akronick has out there and I think I have some good framework now. I'll pull the barrel mod apart and wrap my head around making things work with the mod loader as well.

 

So far I extended a few of codeclub's classes and added some new stuff successfully. I may have screwed something up with the CreationEntryCreator side because my advanced entries are working perfect, but my simple entries are showing up in the crafting recipes book in world a dozen times. They work but haven't quite figured out why they are repeating so many times.

 

I'm also having an issue where so far all the models I'm adding are ending up on their side in world, which is causing most of them to appear black since the texture positioning is wrong. As a GM in world I can see the yaw, pitch, roll is off on the object but I haven't seen a place where you can define any of that in the code. Might be a outright issue with the object and need to figure out how to fix that in the DAE file itself.

 

Still have a number of things to figure out but progess is progress.

Share this post


Link to post
Share on other sites

Well slowly dealing with my DAE issues. Blender does not seem to deal with this particular topic well. Looking forward to obtaining 3DS or Maya at some point. But whatever progress is being made.

 

So here's my latest road block. I'm trying to add some additional tabards or even make the plethora of existing tabards for the kingdoms and PMKs craftable. So I find adding new items pretty easy now that I understand all that well, except wearables. :(

 

So I poked around player\armor.xml to see how the textures are being referenced. However I am not sure how to call all these tabard entries. I thought ok maybe this is like all the rest of the kingdom stuff so in my itemtemplate I used for my model field "model.clothing.tabard.jenn". Obviously just adding the four character kingdom designation used everywhere. No luck put the tabard on and you see nothing. I had done this before I had found the armor.xml So after looking at that I saw they were also referencing the material so I changed my model fields to "model.clothing.tabard.cotton.jenn" and still no luck.

 

So does anyone have any suggestions on how to properly call this? I'm hoping I don't have to add all new entries in the armor.xml file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this