Serene Seasons

Serene Seasons

53M Downloads

[Suggestion] Pam's Hanging Fruits

DevOpDan opened this issue ยท 5 comments

commented

The latest version of SS states in the change-log that

Allowed growable blocks to be listed in the crop fertility config, for crops that don't have seed items. This includes saplings, flowers from other mods, and so on.

Does this include the 'non-ripe' fruit that grows under Pam's Fruit Trees? I've added the apple block (harvestcraft:pamapple) to the Summer fertility list and set the season to Winter and they still grow.
Is it possible to prevent Pam's hanging fruits from growing during seasons?

I'm referring to these:
Pam's Fruit Trees

commented

I went digging around a bit and long story short, it isn't an issue of growth events.

The reason that fruit doesn't work with the seasons is because initSeasonCrops only references IPlantable items and the fruit blocks are not plantable items. Would it break things to change it to IGrowable to include things that can only spawn on their own, like the fruit blocks?

commented

That's not what it is. The IPlantable check is just for seeds, so that we can automatically check for the crop block from listed seeds (But also so the seeds get the fertile season text on their tooltip). There's a separate process for blocks though, which is what these would use.

But you can see here that their fruit blocks don't implement the Forge CropGrowEvent hooks: https://github.com/MatrexsVigil/harvestcraft/blob/master/src/main/java/com/pam/harvestcraft/blocks/growables/BlockPamFruit.java#L207

Which means that their growth cannot be canceled. The actual state setting event looks like this in vanilla crops for example:

if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, rand.nextInt((int)(25.0F / f) + 1) == 0)) { worldIn.setBlockState(pos, this.withAge(i + 1), 2); net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); }

Also, the bonemeal event is handled from the item itself (Which is always going to have the Forge hooks for that event) so if you're only going off of that, it's not really a proper indicator of which crops can/can't work properly.

commented

Ah.... thanks. I am very new to mod code, I didn't see that part. (I was basing it partly off of the whole fertility tooltip thing, but I think that was a red herring.) Sorry for wasting your time! I'll probably go do something awful to my copy of HarvestCraft to try to make this work, then.

commented

You've been super helpful and patient with me so please feel free to ignore this! But I am trying to figure out how to change (or later override?) the HarvestCraft code to make this work and I have this right now in BlockPamFruit

  @Override
  public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    int i = state.getValue(AGE);
    
    if(i < MATURE_AGE) {
      if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, rand.nextInt([long config ref, redacted]) == 0)) {
        worldIn.setBlockState(pos, state.withProperty(AGE, i + 1), 2);
        net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
      }
    }
  }

Based on what you said and on how the BlockPamCrop code looks, this should allow the fruit growth to be cancelled by your mod? But I have both harvestcraft:pamapple and harvestcraft:appleitem set as autumn crops and the season set to spring and the fruit are still growing. I've scoured the code for any other references to grow in respect to fruit in case there's a direct grow event somewhere I missed but I found nothing... Is that even what I should be looking for?

Also, if there's a place that would be better to post about this to get help, point me there and I'll happily get out of your issues section.

EDIT hold on I just remembered that apples are a default item, this is why I was testing with pears last time, ack. I'm going to try it with minecraft:apple in the config.... confirmed it actually doesn't work and isn't just my config being wrong. Tried it with pears, too, harvestcraft:pampear and harvestcraft:pearitem in the config for autumn.

commented

There's probably nothing we can do to allow these to work if they don't use the proper Forge hooks to cancel growth events.