Posted March 23, 20214 yr I want my mod to change how quickly crops grow based on the biome. But when I test my mod the crops grow the same regardless of the biome. I have other methods inside of ModClientEvents that do work and when I add a print statement above the state.randomTick line it gives the correct score that the biomes should have when I am within each biome which means that the method is being called when the event occurs, the method calculates the biome scores connectly, and the code inside of the if statement is being run. This makes me think that the problem is with state.randomTick. How I can fix my code to make it so that state.randomTick actually alters the growth age of crops? @Mod.EventBusSubscriber(modid = AOEMod.MOD_ID, bus=Mod.EventBusSubscriber.Bus.FORGE, value= Dist.CLIENT) public class ModClientEvents { public static double[] growth_chances=new double[]{0,0,1.0/3.0,1.0/2.0,2.0/3.0}; @SubscribeEvent public static void onPlantTick(BlockEvent.CropGrowEvent.Pre event) { IWorld world=event.getWorld(); BlockPos pos=event.getPos(); BlockState state=event.getState(); int score=getScore(world,pos,state.getBlock()); if(world.getRandom().nextDouble()<growth_chances[score]){ state.randomTick((ServerWorld) world,pos,world.getRandom());//NOT WORKING!!! } } } Edited March 23, 20214 yr by Andrew Murdza
March 24, 20214 yr Author I'm sorry for wasting your time I figured out that the reason it wasn't working is because I used to use a different scale of biome scores (with varied between 0 and 2 instead of 0 and 4) which made the crops seem to grow at the same rate. When I scaled the scores by 2 everything worked.
March 24, 20214 yr *Deadpan* Don't use state.randomTick, that fires the vanilla logic again. You want to make the crop grow if your random returns true, set the event's result to ALLOW. https://github.com/MinecraftForge/MinecraftForge/blob/5f9e6f3b567565a38a46c7ccdf5a09c720b974bc/src/main/java/net/minecraftforge/event/world/BlockEvent.java#L345 Edited March 24, 20214 yr by Draco18s 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.
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.