BentoBoxWorld / Greenhouses

BentoBox Add-on to enable personal biomes in a glass greenhouse
Eclipse Public License 2.0
13 stars 9 forks source link

Glow Lichen Spawning Strangely #96

Closed mercurialmusic closed 1 year ago

mercurialmusic commented 1 year ago

Expected behavior

Would expect normal generation of glow_lichen on the block.

Observed/Actual behavior

In Greenhouses, glow_lichen seems to spawn quite strangely when in a recipe, as seen here: https://gyazo.com/98395c5f35d1e5b6d8ae6422dd8aab1b. When harvested properly with shears, they drop nothing.

Steps/models to reproduce

No error, but will include the relevant recipe below:

  DRIPSTONE_CAVES:
    friendlyname: "&6Drippy Drops"
    biome: dripstone_caves
    icon: DRIPSTONE_BLOCK
    priority: 15
    contents:
      STONE: 8
      CLAY: 8
    # 50% water cove rage required
    watercoverage: 25
    conversions:
      CLAY: 50:DRIPSTONE_BLOCK:WATER
      STONE: 0.005:COPPER_ORE:STONE
    plants:
      GLOW_LICHEN: 20:STONE
    mobs:
      skeleton: 5:STONE
      glow_squid: 5:WATER
    moblimit: 5

BentoBox version

[18:43:26 INFO]: Running PAPER 1.19.3. [18:43:26 INFO]: BentoBox version: 1.22.0-SNAPSHOT-b2314 [18:43:26 INFO]: Database: JSON [18:43:26 INFO]: Loaded Game Worlds: [18:43:26 INFO]: acidisland_world (AcidIsland): Overworld, Nether, The End [18:43:26 INFO]: bskyblock_world (BSkyBlock): Overworld, Nether, The End [18:43:26 INFO]: oneblock_world (OneBlock): Overworld, Nether* [18:43:26 INFO]: Loaded Addons: [18:43:26 INFO]: AcidIsland 1.16.0 (ENABLED) [18:43:26 INFO]: AOneBlock 1.12.0-SNAPSHOT-b280 (ENABLED) [18:43:26 INFO]: BSkyBlock 1.16.0 (ENABLED) [18:43:26 INFO]: Challenges 1.1.0-SNAPSHOT-b496 (ENABLED) [18:43:26 INFO]: DimensionalTrees 1.6.1-SNAPSHOT-b84 (ENABLED) [18:43:26 INFO]: Greenhouses 1.7.0-SNAPSHOT-b324 (ENABLED) [18:43:26 INFO]: Level 2.10.0-SNAPSHOT-b516 (ENABLED) [18:43:26 INFO]: Limits 1.19.1-SNAPSHOT-b301 (ENABLED) [18:43:26 INFO]: Warps 1.13.0-SNAPSHOT-b329 (ENABLED)

Plugin list

No response

Other

No response

tastybento commented 1 year ago

Hmm, yes, this type of "plant" requires special handling because it has to be applied to a block face. I'm having difficulty making it work though and I'm not sure why (unless the API is broken). @BONNe any ideas? Here's my current code:

if (p.plantMaterial().equals(Material.GLOW_LICHEN)) {
           // Find an adjacent block that is air to become lichen
            Block b = bl.getRelative(BlockFace.DOWN);
            // Look around block
            BlockFace d = BlockFace.NORTH;
            if (b.getRelative(BlockFace.NORTH).getType().equals(Material.AIR)) {
                d = BlockFace.NORTH;
            } else if (b.getRelative(BlockFace.SOUTH).getType().equals(Material.AIR)) {
                d = BlockFace.SOUTH;
            } else if (b.getRelative(BlockFace.EAST).getType().equals(Material.AIR)) {
                d = BlockFace.EAST;
            } else if (b.getRelative(BlockFace.WEST).getType().equals(Material.AIR)) {
                d = BlockFace.WEST;
            } else {
                BentoBox.getInstance().logDebug("No face found");
                return false;
            }
            Block bb = b.getRelative(d);
            bb.setType(Material.GLOW_LICHEN);
            BlockFace opp = d.getOppositeFace();
           // Wait a tick just in case
            Bukkit.getScheduler().runTask(addon.getPlugin(), () -> {
                if(bb.getState().getData() instanceof GlowLichen){
                    // This never gets to execute....
                    BentoBox.getInstance().logDebug("Setting Glow Lichen");
                    GlowLichen v = (GlowLichen) b.getState().getData();
                    for (BlockFace f : v.getAllowedFaces()) {
                        BentoBox.getInstance().logDebug("Setting " + f);
                        v.setFace(f, false);
                    }
                    v.setFace(opp, true);
                    bb.setBlockData(v);
                    bb.getState().setBlockData(v);
                    bb.getState().update(true);
                } else {
                    BentoBox.getInstance().logDebug("Not a Glow Lichen block, hmmm");
                }
            });

Although I wait for one tick after setting the block to glow lichen, the block state never becomes lichen and I see this in the log:

[19:09:10] [Server thread/INFO]: [BentoBox] DEBUG: Not a Glow Lichen block, hmmm
[19:09:10] [Server thread/INFO]: [BentoBox] DEBUG: Not a Glow Lichen block, hmmm
[19:09:10] [Server thread/INFO]: [BentoBox] DEBUG: Not a Glow Lichen block, hmmm

I added the tick because I thought would help but the same thing occurs if you don't wait. If you don't do the instance check you get a cast error. In the game the block becomes Glow Lichen but all 6 faces are represented, so the block is basically air with lichen on all sides.

tastybento commented 1 year ago

Unblocked...

tastybento commented 1 year ago

Okay, this should work now. Thanks @BONNe for pointing out my mistake.

tastybento commented 1 year ago

Snapshot builds are here: https://ci.codemc.io/job/BentoBoxWorld/job/Greenhouses/

mercurialmusic commented 1 year ago

Thank you!