Jump to content

Recommended Posts

Posted

Hello,

 

I got a bit of a problem with my crop.

 

I wanted that my plant (when its fully grown) drops 1 --> 2 seeds and 1 --> 3 "strawberry's", the only problem that I have is when I add

public int quantityDropped (Random random) {

return 1+r.nextInt(3);

}

It counts for both, as well the strawberry's and seeds.

 

I wanted to have a quantitydropped for my strawberry's, and one for my seeds.

How do I do that?

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Posted

Override

public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)

instead

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

Look at the function in Item.java

 

You return an ArrayList of ItemStacks

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

I think I know what it getDrops is now, But I have some trouble with my stages.

 

I now got multiple items at the last stage, but I want "green paprika" at stage 5, "yellow paprika" at stage 6, "red paprika" at stage 7.

Otherwise, just the seeds.

 

Here's my code:

http://pastebin.com/rwVCQdny

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Posted

Hi

 

I guess you got a little confused by 'stage' and 'meta'.

 

You want to check the meta data before adding ItemStacks to the ArrayList in getDrops.

 

The metadata is given, so something like:

switch(metadata){
case 5:
//add desired paprika to ret
break;
case 6:
//the other paprika
break;
case 7:
//the last one
break;
default:
//add seeds to the list
break;
}

 

Hope that helped.

 

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, I have my crop dropping '3' at stage 5, 6 and 7. and 1 seed at the other stages.

 

But I have still a problem:

 

Sometimes my log says my plant that is fully grown has stage 0 (or other) what means that I get sometimes seeds when its fully grown. Thanks.

 

I tried your switch and break, case thing, but my break gives an error, "Unreacheble code" but, This is my code:

 

http://pastebin.com/jtMQB3Vs

 

Thanks.

 

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Posted

Hi

 

Uh, it looks like you did not understand one core mechanic in minecraft:

 

Each item and each block as only ONE SINGLE object at run time (guess why).

So your 'bufferstage' thingy will never work!

 

I'd recommend you the follwing changes to your code:

 

1. Rewrite the getItemDropped method and always return 1 (or any number of 'default' seed amount).

2. Rewrite the getItemDropped method to return the default output (e.g. seeds)

3. Write the getDrops method as following:

3.1 If metadata equals the 'green-Stage', then add (maybe multiple times) the green paprika to the output ArrayList.

3.2 If 'metadata' equals 'red-Stage', then add (maybe multiple times) the green paprika to the output ArrayList

3.3 If 'metadata' equals 'yellow-Stage', then add (maybe multiple times) the yellow paprika.

3.4 For any other 'metadata' add your seed item to the ArrayList.

 

An example for the getDrops method body(please just don't copy paste it'):

 

ArrayList<ItemStack> result = new ArrayList<ItemStack>;
int amount = world.rand.nextInt(MAX_DROPS) + 1;
int bonusMultiplier = 2;
int bonusChance = world.rand.nextInt(10);
if(bonusChance < fortune){
//so the fortune level equals the chance to get the double
//amount of drops in %, multipied with 10 (e.g. fortune I => 10% chance)
//double drops.
amount *= bonusMultiplier;
}
for(int i=0; i<amount; i++){
switch(metadata){
	case GREEN_STAGE:
		result.add(ModItems.greenPaprikaItem);//the object of your item
	break;
	case RED_STAGE:
		result.add(ModItems.redPaprikaItem);//red one
	break;
	case YELLOW_STAGE:
		result.add(ModItems.yellowPaprikaItem);//yellow
	break;
}
}
if(metadata != GREEN_STAGE || metadata != RED_STAGE || metadata != YELLOW_STAGE){
result.add(ModItems.paprikaSeeds);//Or in a for loop if you want several seeds
}
return result;

 

 

But to get back to one of your questions:

If you have a construct like

switch(someValue){
    case 1:
        return something;
    break;
}

The break -statement is unreachable, because you return a line before it.

 

May this reply is helpful

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

This reply is very helpful!

 

Thanks, it now works fine and I now understand much more about the java code.

 

Thank you for helping!

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So i have a forge modded aternos server that worked just fine for a month untill today it suddenly crashes most of the time giving errors and idk which mod is causing the error or its smth else here is the crash log link https://mclo.gs/gGkzGKT
    • Struggling to decipher a crash report I'm getting in a custom modpack I'm tinkering with. The crash happens on startup, but weirdly, only some of the time. It seems to be related to Steves Carts, but weirdly it only started happening recently, and I can't identify if another mod is conflicting, or why it is only happening some of the time:   java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.player.Player.m_20202_()" because "player" is null at vswe.stevescarts.events.OverlayEventHandler.onRenderTick(OverlayEventHandler.java:24) ~[stevescarts-1.20.1-1.1.14.jar%23527!/:1.20.1-1.1.14] {re:classloading} at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:260) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:252) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(ForgeEventFactory.java:919) ~[forge-1.20.1-47.1.106-universal.jar%23581!/:?] {re:mixin,re:classloading,pl:mixin:APP:modernfix-forge.mixins.json:perf.potential_spawns_alloc.ForgeEventFactoryMixin,pl:mixin:A} at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1148) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:218) ~[minecraft-1.20.1-client.jar:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:flywheel.mixins.json:ClientMainMixin,pl:mixin:A,pl:runtimedistcleaner:A}     Including some extra info in case any of it is relevant^. Appreciate any ideas/advice!    
    • Try the JVM argument in this post, just sub xmx/xms numbers for what you want/need allocated.  https://www.reddit.com/r/feedthebeast/s/lzmKUNZFrG I'm having the same issue with a huge modpack using the 3 culprits to your issue.  Let me know if this helps!
    • i have been trying to  lauch a modpack and it crashes in the lauching phase   
    • nope, even the log is the exact same, i also tried with the Dimensional doors just in case and nothing.
  • Topics

×
×
  • Create New...

Important Information

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