Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7214

CraftChunk and CraftChunkSnapshot contains biome

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • CraftBukkit version 3627-Spigot-d90018e-c810c3e (MC: 1.19.3) (Implementing API version 1.19.3-R0.1-SNAPSHOT)
    • Yes

      It is very difficult to check if a chunk contains a biome without using reflection and NMS. I believe this is the correct code that can be implemented for these features.

      CraftChunk:

          public boolean contains(org.bukkit.block.Biome biome) {
              Preconditions.checkArgument(biome != null, "Biome cannot be null");
      
              Holder<net.minecraft.world.level.biome.Biome> biomeHolder = CraftBlock.biomeToBiomeBase(this.getHandle().biomeRegistry, biome);
              Predicate<Holder<net.minecraft.world.level.biome.Biome>> nms = Predicates.equalTo(biomeHolder);
              for (LevelChunkSection section : this.getHandle().getSections()) {
                  if (section != null && section.getBiomes().maybeHas(nms)) {
                      return true;
                  }
              }
      
              return false;
          }
      

      CraftChunkSnapshot:
       

      public boolean contains(org.bukkit.block.Biome biome biome) {
       Preconditions.checkArgument(biome != null, "Biome cannot be null"); 
       Holder<net.minecraft.world.level.biome.Biome> biomeHolder = CraftBlock.biomeToBiomeBase(biomeRegistry, biome);
      Predicate<Holder<net.minecraft.world.level.biome.Biome>> nms = Predicates.equalTo(biomeHolder);
      for(PalettedContainerRO<Holder<net.minecraft.world.level.biome.Biome>> palettedContainerRO : this.biome) {
      if(palettedContainerRO.maybeHas(nms))
      { return true; }
      }
      return false;
      }
      

       

            Unassigned Unassigned
            Mersphydena Mersphydena
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: