1.15.2 Géneration de Structure bug



  • Bonjour je suis en train de créer une nouvelle structure utilisant les blocs de jigsaw mais la structure ne se génère pas (les coordonné donné par le /locate fait arriver dans une zone vide
    voici donc les classe:
    StructureInit:

    package eris.greatvisitor.mod.init;
    
    import eris.greatvisitor.mod.GreatVisitor;
    import eris.greatvisitor.mod.world.structure.TowerStructure;
    import net.minecraft.world.gen.feature.Feature;
    import net.minecraft.world.gen.feature.NoFeatureConfig;
    import net.minecraft.world.gen.feature.structure.Structure;
    import net.minecraftforge.fml.RegistryObject;
    import net.minecraftforge.registries.DeferredRegister;
    import net.minecraftforge.registries.ForgeRegistries;
    
    
    public class StructureInit{
    	 public static final DeferredRegister<Feature<?>> FEATURES = new DeferredRegister<>(ForgeRegistries.FEATURES, GreatVisitor.MOD_ID);
    	 public static final RegistryObject<Structure<NoFeatureConfig>> TOWER_STRUCTURE = register("tower_structure", new TowerStructure(NoFeatureConfig::deserialize));
    	 
    	    private static <T extends Feature<?>> RegistryObject<T> register(String name, T feature) {
    	        return FEATURES.register(name, () -> feature);
    	    }
    }
    

    structurePieceInit:

    public class StructurePieceInit {
        // Structure Pieces
        public static final IStructurePieceType TOWER_STRUCTURE = register("tower_structure", TowerPieces.Tower::new);
        
        private static IStructurePieceType register(String key, IStructurePieceType type) {
            return Registry.register(Registry.STRUCTURE_PIECE, new ResourceLocation(GreatVisitor.MOD_ID, key), type);
        }
    }
    
    
    

    towerStructure:

    
    public class TowerStructure extends ScatteredStructure<NoFeatureConfig> {
    
    
        
        public static final String NAME = GreatVisitor.MOD_ID + ":Tower";
        private static final int CHUNK_RADIUS = 3;
        private static final int FEATURE_DISTANCE = 35;
        private static final int FEATURE_SEPARATION = 8;
    
        public TowerStructure(Function<Dynamic<?>, ? extends NoFeatureConfig> deserialize) {
            super(deserialize);
        }
    
        @Override @Nonnull
        public IStartFactory getStartFactory() {
            return Start::new;
        }
    
        @Override @Nonnull
        public String getStructureName() {
            return NAME;
        }
    
        @Override
        public int getSize() {
            return CHUNK_RADIUS;
        }
    
        @Override
        protected ChunkPos getStartPositionForPosition(ChunkGenerator<?> chunkGenerator, Random random, int x, int z, int spacingOffsetsX, int spacingOffsetsZ) {
            int k = x + FEATURE_DISTANCE * spacingOffsetsX;
            int l = z + FEATURE_DISTANCE * spacingOffsetsZ;
            int i1 = k < 0 ? k - FEATURE_DISTANCE + 1 : k;
            int j1 = l < 0 ? l - FEATURE_DISTANCE + 1 : l;
            int k1 = i1 / FEATURE_DISTANCE;
            int l1 = j1 / FEATURE_DISTANCE;
            ((SharedSeedRandom)random).setLargeFeatureSeedWithSalt(chunkGenerator.getSeed(), k1, l1, 10387312);
            k1 = k1 * FEATURE_DISTANCE;
            l1 = l1 * FEATURE_DISTANCE;
            k1 = k1 + random.nextInt(FEATURE_DISTANCE - FEATURE_SEPARATION);
            l1 = l1 + random.nextInt(FEATURE_DISTANCE - FEATURE_SEPARATION);
            return new ChunkPos(k1, l1);
        }
        
        public boolean canBeGenerated(BiomeManager manager, ChunkGenerator<?> generator, Random random, int chunkX, int chunkZ, Biome biome) {
            ChunkPos chunkpos = this.getStartPositionForPosition(generator, random, chunkX, chunkZ, 0, 0);
            if (chunkX == chunkpos.x && chunkZ == chunkpos.z) {
                for(Biome biome1 : generator.getBiomeProvider().getBiomes(chunkX * 16 + 9, generator.getSeaLevel(), chunkZ * 16 + 9, 32)) {
                    if (!generator.hasStructure(biome1, this)) {
                        return false;
                    }
                }
                Random random1 = new Random((long)(chunkX + chunkZ * 10387313));
                Rotation rotation = Rotation.values()[random1.nextInt(Rotation.values().length)];
                int i = 5;
                int j = 5;
                if (rotation == Rotation.CLOCKWISE_90) {
                    i = -5;
                } else if (rotation == Rotation.CLOCKWISE_180) {
                    i = -5;
                    j = -5;
                } else if (rotation == Rotation.COUNTERCLOCKWISE_90) {
                    j = -5;
                }
    
                int k = (chunkX << 4) + 7;
                int l = (chunkZ << 4) + 7;
                int i1 = generator.func_222531_c(k, l, Heightmap.Type.WORLD_SURFACE_WG);
                int j1 = generator.func_222531_c(k, l + j, Heightmap.Type.WORLD_SURFACE_WG);
                int k1 = generator.func_222531_c(k + i, l, Heightmap.Type.WORLD_SURFACE_WG);
                int l1 = generator.func_222531_c(k + i, l + j, Heightmap.Type.WORLD_SURFACE_WG);
                int minHeight = Math.min(Math.min(i1, j1), Math.min(k1, l1));
                int maxHeight = Math.max(Math.max(i1, j1), Math.max(k1, l1));
                if (maxHeight - minHeight < 2 && maxHeight - minHeight > -2) {
                    return true;
                }
                return false;
            } else {
                return false;
            }
        }
    
        @Override
        protected int getSeedModifier() {
            return 14357618;
        }
    
        public static class Start extends MarginedStructureStart {
    
            public Start(Structure<?> p_i225874_1_, int p_i225874_2_, int p_i225874_3_, MutableBoundingBox p_i225874_4_, int p_i225874_5_, long p_i225874_6_) {
                super(p_i225874_1_, p_i225874_2_, p_i225874_3_, p_i225874_4_, p_i225874_5_, p_i225874_6_);
            }
    
            @Override
            public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn) {
                Random random = new Random((long)(chunkX + chunkZ * 10387313));
                Rotation rotation = Rotation.values()[random.nextInt(Rotation.values().length)];
                int i = 5;
                int j = 5;
                if (rotation == Rotation.CLOCKWISE_90) {
                    i = -5;
                } else if (rotation == Rotation.CLOCKWISE_180) {
                    i = -5;
                    j = -5;
                } else if (rotation == Rotation.COUNTERCLOCKWISE_90) {
                    j = -5;
                }
    
                int k = (chunkX << 4) + 7;
                int l = (chunkZ << 4) + 7;
                int i1 = generator.func_222531_c(k, l, Heightmap.Type.WORLD_SURFACE_WG);
                int j1 = generator.func_222531_c(k, l + j, Heightmap.Type.WORLD_SURFACE_WG);
                int k1 = generator.func_222531_c(k + i, l, Heightmap.Type.WORLD_SURFACE_WG);
                int l1 = generator.func_222531_c(k + i, l + j, Heightmap.Type.WORLD_SURFACE_WG);
                int minHeight = Math.min(Math.min(i1, j1), Math.min(k1, l1));
                int maxHeight = Math.max(Math.max(i1, j1), Math.max(k1, l1));
                if (maxHeight - minHeight < 2 && maxHeight - minHeight > -2) {
                    BlockPos blockpos = new BlockPos(chunkX * 16, minHeight, chunkZ * 16);
                    TowerPieces.func_215139_a(generator, templateManagerIn, blockpos, this.components, this.rand);
                    this.recalculateStructureSize();
                }
            }
        }
    
    
    		
    	
    }
    

    et TowerPiece:

    
    public class TowerPieces {
    	   public static void func_215139_a(ChunkGenerator<?> chunkGeneratorIn, TemplateManager templateManagerIn, BlockPos posIn, List<StructurePiece> structurePieces, SharedSeedRandom p_215139_4_) {
    		      JigsawManager.func_214889_a(new ResourceLocation("tower_structure/brain"), 7, TowerPieces.Tower::new, chunkGeneratorIn, templateManagerIn, posIn, structurePieces, p_215139_4_);
    		   }
    
    		   static {
    			   	JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("tower_structure/brain"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new SingleJigsawPiece("tower_structure/pattern"), 1)), JigsawPattern.PlacementBehaviour.RIGID));			     
    			    JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("tower_structure/pattern"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new SingleJigsawPiece("tower_structure/pattern1"), 1), Pair.of(new SingleJigsawPiece("tower_structure/pattern"), 1), Pair.of(new SingleJigsawPiece("tower_structure/pattern2"), 1), Pair.of(new SingleJigsawPiece("tower_structure/pattern_end"), 1), Pair.of(new SingleJigsawPiece("tower_structure/stair"), 1), Pair.of(EmptyJigsawPiece.INSTANCE, 6)), JigsawPattern.PlacementBehaviour.RIGID));
    			    JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("tower_structure/tower_top"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new SingleJigsawPiece("tower_structure/forteress_core_top"), 1)), JigsawPattern.PlacementBehaviour.RIGID));			     
    				JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation("tower_structure/tower_bottom"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new SingleJigsawPiece("tower_structure/forteress_core_bottom"), 1)), JigsawPattern.PlacementBehaviour.TERRAIN_MATCHING));			     
    
    		   }
    
    		   public static class Tower extends AbstractVillagePiece {
    			      public Tower(TemplateManager templateManagerIn, JigsawPiece jigsawPieceIn, BlockPos posIn, int p_i50560_4_, Rotation rotationIn, MutableBoundingBox boundsIn) {
    			         super(IStructurePieceType.PCP, templateManagerIn, jigsawPieceIn, posIn, p_i50560_4_, rotationIn, boundsIn);
    			      }
    
    			      public Tower(TemplateManager templateManagerIn, CompoundNBT nbt) {
    			         super(templateManagerIn, nbt, IStructurePieceType.PCP);
    			      }
    			   }
    		
    }
    

    Si vous savez comment régler se problème merci de me dire comment
    PS.Je suis sur java 8 forge 31.1.0


Log in to reply