Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello everybody,

 

how can i effect plant? Like the Watering Can from Extra Utility or Imaginary Time Block from Quantum Flux?

I cant find source code for 1.8 and want to know how i could add a greenhouse to my mod.

 

Thanks for the answer,

Kaneka

How do you want to effect it? Do you want to use an item like a watering can to increase growth rate like ExtraUtilities adds? If so, I can help with the code in 1.7.10, I haven't looked into 1.8 just yet though as most mods I play are 1.7.10 still so I'm making mine in 1.7.10 for now.

 

If that's the effect you want, look at bonemeal functions or just look at how a plant grows. It has a random chance during it's updateTick to increase metadata (aka the growth stage). So on your item's onItemUse you can check if the block you are using it on is an instance of blockCrop for example, if so give a random chance to increase metadata by one .setBlockMetadataWithNotify(...);

 

Here is an example of a debug item I use as a tool to increment/decrement my crop's growth stage (metadata) if its an instance of my crops specifically (OrePlant), the player is in creative, and the metadata isn't already at full grown or lower than 0. You would replace 7 with whatever your max growth stage is, so you may want to call that into a variable. All of my ore plants have a stage of 7 so I hard coded it, but I will likely go recode that later into a variable just to make things better. I can include the full file if you need me to.

 

NOTE: THIS IS TESTED IN 1.7.10, I haven't tested it in 1.8 so methods may be changed.

 

public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int worldX, int worldY, int worldZ, int blockSide, float p_77648_8_, float p_77648_9_, float p_77648_10_)
    {
        int blockMeta = world.getBlockMetadata(worldX, worldY, worldZ);
        Block block = world.getBlock(worldX, worldY, worldZ);
        Boolean isOrePlant = block instanceof OreCrystalPlant;
        Boolean isCreative = player.capabilities.isCreativeMode;

        if(blockMeta < 7 && !player.isSneaking() && isOrePlant && isCreative) //metaData cant go past 7, player is not sneaking. This is on our OrePlant.
        {
            blockMeta += 1;
            world.setBlockMetadataWithNotify(worldX, worldY, worldZ, blockMeta, 2);
        }

 

So for the watering can I would add to that if statement (or nest all of this into an if statement) that does a random number, give it whatever % (like rand <=25 would be 25%) and let it increment.

www.YouTube.com/WeiseGamer

www.twitter.com/WeiseGamer

I cant find source code for 1.8...

When you installed Forge for development, did you specify "setupDecompWorkspace"? If not, then you may want to install it again. Once you have the "Decomp" setup, then you'll find a mostly deobfuscated transformation of vanilla source code in <ForgeDir>\build\tmp\recompSrc. The java is under "net", and json files are under "assets". All of the blocks and items and entities and achievements etc are there to be studied, called, extended, imitated (and copy-pasted and reflected).

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.

  • Author

I cant find source code for 1.8...

When you installed Forge for development, did you specify "setupDecompWorkspace"? If not, then you may want to install it again. Once you have the "Decomp" setup, then you'll find a mostly deobfuscated transformation of vanilla source code in <ForgeDir>\build\tmp\recompSrc. The java is under "net", and json files are under "assets". All of the blocks and items and entities and achievements etc are there to be studied, called, extended, imitated (and copy-pasted and reflected).

 

I can find the source code of vanilla in 1.8, but not that one for the watering can and imaginary time block

 

How do you want to effect it? Do you want to use an item like a watering can to increase growth rate like ExtraUtilities adds? If so, I can help with the code in 1.7.10, I haven't looked into 1.8 just yet though as most mods I play are 1.7.10 still so I'm making mine in 1.7.10 for now.

 

If that's the effect you want, look at bonemeal functions or just look at how a plant grows. It has a random chance during it's updateTick to increase metadata (aka the growth stage). So on your item's onItemUse you can check if the block you are using it on is an instance of blockCrop for example, if so give a random chance to increase metadata by one .setBlockMetadataWithNotify(...);

 

Here is an example of a debug item I use as a tool to increment/decrement my crop's growth stage (metadata) if its an instance of my crops specifically (OrePlant), the player is in creative, and the metadata isn't already at full grown or lower than 0. You would replace 7 with whatever your max growth stage is, so you may want to call that into a variable. All of my ore plants have a stage of 7 so I hard coded it, but I will likely go recode that later into a variable just to make things better. I can include the full file if you need me to.

 

 

thanks for the answer, but i thing i will try to use the code from the bonemeal to support other mods crops too.

But i dont like your thinking of the 1.7.. the biggest problem of 1.8 is that all think " lets stay on 1.7" but as you can read in other threads of me that to get 1.8 focused, more modder have to jump on the 1.8 train and update to 1.8 or start in 1.8.

Check what bonemeal does.

 

A Watering can works like Bonemeal?

 

I'm not sure but I think the watering can works different. Can't explain why but what is does is different to just applying bone meal.

 

Bonemeal seems to randomly increase metadata, but not always by just 1 stage. Any mod that has a crop will very likely be using metadata to control its growth. You need an item to increment meta data. Not sure why you don't think that would work for you, especially when I'm saying I've made what you described to effect growth rate of a single block, which can easily be expanded to a 3x3 area like the extra utilities can will.

 

 

www.YouTube.com/WeiseGamer

www.twitter.com/WeiseGamer

Bonemeal seems to randomly increase metadata, but not always by just 1 stage. Any mod that has a crop will very likely be using metadata to control its growth. You need an item to increment meta data. Not sure why you don't think that would work for you, especially when I'm saying I've made what you described to effect growth rate of a single block, which can easily be expanded to a 3x3 area like the extra utilities can will.

 

Well, from what I remember from the watering can, it also works on blocks where Bonemeal doesn't work, like sugar canes and cactus.

So maybe it's a combination of metadata and some other information used for those blocks to decide if they can grow taller or not.

The Watering Can schedules block updates with

World#scheduleBlockUpdate

when it detects a plant (

IPlantable

or

IGrowable

) in its area of effect.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.