Posted February 4, 20169 yr Hey folks, I am triing to rework how crops work. What I am triing to achieve is that crops, that are fully grown and dont get harvested go bad after a specific time. Sadly Im not sure how to do that. One idea I had was to subscribe to the event that was fired when IGrowable groes, and start a timer there (mb TickEvent or MinecraftQueue) that will check if the crop is still there after x seconds, but Im not sure if that is the correct approach. Any help is appreciated. Greetz Fail
February 4, 20169 yr You will need ASM. Alternatively you can try basing your mood off of AppleCore (which does that for you) and hiking into the appropriate events. 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.
February 5, 20169 yr Author Alright. I am at the point where I feel totally retarded. The mod wants me to get 1.8.9 . But I cant find forge for 1.8.9, only for 1.8 which seems to get me 1.8.0
February 5, 20169 yr http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
February 5, 20169 yr Download Recommended 1.8.9 - 11.15.1.1722 BTW, Have you looked at how crops grow in the first place? Can you see a way to override a method so that the final stage has a chance to roll around to the 1st stage? The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
February 5, 20169 yr Can you see a way to override a method so that the final stage has a chance to roll around to the 1st stage? I would assume the term 'spoil', even in Minecraft terms, doesn't mean returning to seedling stage, but I could be wrong Crops generally use a metadata-based growing system with the block's age (i.e. metadata, typically using the first 3 of the 4 available bits) incrementing randomly during the block's update tick. I'm not aware of any global notification that occurs for metadata / state changes, so without introducing your own via ASM or using an existing API that does so as Draco suggested, I don't think it would be possible. EDIT: Actually, there is the Forge block snapshot system that was added somewhat recently (recently being within the last year or so...). That might be the hook you are looking for. http://i.imgur.com/NdrFdld.png[/img]
February 5, 20169 yr Author @SubscribeEvent public void onPlantGrowth(GrowthTick event) { if(event.world.isRemote) return; if(event.block instanceof IGrowable) { IGrowable growable = (IGrowable) event.block; if(!growable.canGrow(event.world, event.pos, event.currentState, false)) { addDecayer(new PlantDecayer(event.currentState, event.pos, event.world, TIME_TO_DECAY_MIN+event.world.rand.nextInt(TIME_TO_DECAY_RND))); } } } This is what I am doing right now. The add decayer is registering the position to a watcher that is a tick handler that checks after x seconds if the plant is still there. There you could just go ahead and get the blockstate with metadata 0, because thats normally the seed stage. Even if thats not what im triing to accomplish :b
February 5, 20169 yr Question for you: does it persist across the save-load boundary? 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.