How would you override the default apple that drops from trees and replace it with a custom item of your own? I have limited knowledge of JAVA so I kindly ask if you could include examples, I have made a custom tree, and I am just trying to figure out how to make the leaves drop a custom apple I made, but I have been unable to figure it out myself.
You need to set the drop item of the leaves to be a chance of dropping your custom apple by using an if on a random number and if it matches a certain number or range of numbers then drop the apples (with amount if desired)
//getItemDropped method
return ModItems.CUSTOM_APPLE
//quantityDropped method
return random.nextInt(5);
This is in 1.12.2 btw, so I don't know what version you're in. It could be slightly different for you but relatively the same.
Rollback Post to RevisionRollBack
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
I thought I told you to use the quantityDropped method override, and inside there just use an if to check if the random parameter's nextInt(whatever chance) is a certain number, and drop a certain number. So for example
How would you override the default apple that drops from trees and replace it with a custom item of your own? I have limited knowledge of JAVA so I kindly ask if you could include examples, I have made a custom tree, and I am just trying to figure out how to make the leaves drop a custom apple I made, but I have been unable to figure it out myself.
You need to set the drop item of the leaves to be a chance of dropping your custom apple by using an if on a random number and if it matches a certain number or range of numbers then drop the apples (with amount if desired)
//getItemDropped method
return ModItems.CUSTOM_APPLE
//quantityDropped method
return random.nextInt(5);
This is in 1.12.2 btw, so I don't know what version you're in. It could be slightly different for you but relatively the same.
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.
sorry for late reply, im confused on how to setup the if statement, I am trying to do this in 1.12.2, any help on the code is greatly appreciated!!
I thought I told you to use the quantityDropped method override, and inside there just use an if to check if the random parameter's nextInt(whatever chance) is a certain number, and drop a certain number. So for example
int chance = 5;
int randomResult = random.nextInt(chance);
if(randomResult == 0) return ModItems.SOME_ITEM;
else if(randomResult == 1) return ModItems.SOME_OTHER_ITEM;
else if(randomResult == 2) return ModItems.YOU_GET_IT;
The quantityDropped method has a random passed into it so you can use that.
If you would like to get a hold of me somehow, then my discord is @Alex Couch#5275.