Is there ways to condense similar item's classes into one? For example, if I wanted to make 2 items that both serve the same function (spawning a mob), but they spawn a different mob. Would it be possible to do this with one class? Or will it require multiple?
Is there ways to condense similar item's classes into one? For example, if I wanted to make 2 items that both serve the same function (spawning a mob), but they spawn a different mob. Would it be possible to do this with one class? Or will it require multiple?
I think this is possible with item metadata, like how dyes are all in the same class but are different items in the game. (not sure though, I'm pretty nooby). Have a look at the dye source code maybe?
Rollback Post to RevisionRollBack
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
Because what I want to do is have two separate areas of code in a SINGLE class, and each of those areas of code will have a respective item 'assigned' to them.
So, what I want to do is make my own kind of item (yes, similar to the spawn egg) which has many similar variants (But they all have around one or two lines edited). I don't want to make many different kinds of classes JUST because I need to edit 2 lines or so in each class. I want to do something SIMILAR to metadata, where in the class file for this item it has different numbers, and each number has certain bits of code assigned to it. So for example, in a class called "VariantItems" I have the numbers 1 and 2. Under 1 I have code which spawns a cow. And under 2 I have code which spawns a slime. And in my main mod file, I have a line of code which makes an item which uses code from number 1 (itemOne = new VariantItems()), and another line of code which uses code from number 2.. (itemTwo = new VariantItems()).
I just basically want to condense code for multiple items into one, and be able to make new items from each of those bits of code.
So, what I want to do is make my own kind of item (yes, similar to the spawn egg) which has many similar variants (But they all have around one or two lines edited). I don't want to make many different kinds of classes JUST because I need to edit 2 lines or so in each class. I want to do something SIMILAR to metadata, where in the class file for this item it has different numbers, and each number has certain bits of code assigned to it. So for example, in a class called "VariantItems" I have the numbers 1 and 2. Under 1 I have code which spawns a cow. And under 2 I have code which spawns a slime. And in my main mod file, I have a line of code which makes an item which uses code from number 1 (itemOne = new VariantItems()), and another line of code which uses code from number 2.. (itemTwo = new VariantItems()).
I just basically want to condense code for multiple items into one, and be able to make new items from each of those bits of code.
Well... I'll look into that and try to work with it, though I can't guarantee any help (I'm quite a noob). If I may ask, what is the project for?
Rollback Post to RevisionRollBack
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
So, I'll have 2 different items (spawn eggs), and a class named 'ItemVariants', and in my main mod class I'll have code like this: "itemOne = new ItemVariants(1)" and "itemTwo = new ItemVariants(2)". So, for example in the ItemVariants class I'll have 1 and 2... and (similar to metadata) it will grab the number and add on the code to the item with the respective number in the ItemVariants file. Honestly, now that I think this through some more, I REALLY doubt it'll be possible. Ah well.
public SlimeSpawnerItem(Entity par1Entity) {
}
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffSet)
{
{
par1Entity ent = new par1Entity(world); //change to whatever entity you're trying to spawn
ent.setLocationAndAngles(x, y + 1, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F);
ent.initCreature();
world.spawnEntityInWorld(ent);
}
}
}
Under 'par1Entity' (On the 'par1Entity ent = new par1Entity.... etc line) it says: par1Entity cannot be resolved to a type
I think this is possible with item metadata, like how dyes are all in the same class but are different items in the game. (not sure though, I'm pretty nooby). Have a look at the dye source code maybe?
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
Why? Oh and actually, looking at your "example", you might want to look at the class for spawn eggs instead.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
So, what I want to do is make my own kind of item (yes, similar to the spawn egg) which has many similar variants (But they all have around one or two lines edited). I don't want to make many different kinds of classes JUST because I need to edit 2 lines or so in each class. I want to do something SIMILAR to metadata, where in the class file for this item it has different numbers, and each number has certain bits of code assigned to it. So for example, in a class called "VariantItems" I have the numbers 1 and 2. Under 1 I have code which spawns a cow. And under 2 I have code which spawns a slime. And in my main mod file, I have a line of code which makes an item which uses code from number 1 (itemOne = new VariantItems()), and another line of code which uses code from number 2.. (itemTwo = new VariantItems()).
I just basically want to condense code for multiple items into one, and be able to make new items from each of those bits of code.
Well... I'll look into that and try to work with it, though I can't guarantee any help (I'm quite a noob). If I may ask, what is the project for?
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
Are you trying to check the metadata on the item before you spawn a mob so it spawns the correct one, or do you want to make :
and have that be 2 spawn eggs? Or are you simply doing something else?
Art by me: MrPancakeWolfie@DeviantArt
So, I'll have 2 different items (spawn eggs), and a class named 'ItemVariants', and in my main mod class I'll have code like this: "itemOne = new ItemVariants(1)" and "itemTwo = new ItemVariants(2)". So, for example in the ItemVariants class I'll have 1 and 2... and (similar to metadata) it will grab the number and add on the code to the item with the respective number in the ItemVariants file. Honestly, now that I think this through some more, I REALLY doubt it'll be possible. Ah well.
No.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
Well, that was funny while it lasted. I think I (might) have a solution. Using integers, make it
===================================================================================================
public void onItemRightclick(params and stuff here) {
spawning code here editing an integer in the ItemVariants class making it decide which slime to spawn
}
and in the ItemVariants class an int maybe called slimelevel or something, and use an if statement to see if the int is correct.
===================================================================================================
If that doesn't work, I have no idea.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
Art by me: MrPancakeWolfie@DeviantArt
Under 'par1Entity' (On the 'par1Entity ent = new par1Entity.... etc line) it says: par1Entity cannot be resolved to a type
im2awsm, did you try my method? I would just like to know if what I said was even correct in the first place.
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
It worked?
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!
So problem solved? I was actually a help?
If you thought something was missing in Minecraft, think again.
MoreMine is coming soon for Minecraft 1.7.10
If I helped you, hit that green arrow!