I was playing around with structures the other day, and I found that I was able to get one working quite easily. I went on to the next step, and took a look at some other mods/some vanilla structures that use Jigsaw blocks. I put something together, but I'm having trouble getting the structure pieces (even just the starting piece) to spawn in the world. I am able to spawn the individual pieces with a structure block in-game perfectly fine though.
The logger shows that it's attempting to spawn the structure, but none of the pieces are ever created. I was wondering if I was doing something wrong with the piece class:
public class PathDungeonPieces {
public static void start(ChunkGenerator<?> chunkGeneratorIn, TemplateManager templateManagerIn, BlockPos posIn, List<StructurePiece> structurePieces, SharedSeedRandom p_215139_4_) {
DungeonMod.LOGGER.info("Adding pieces...");
JigsawManager.addPieces(new ResourceLocation(DungeonMod.MOD_ID, "path_dungeon/center"), 7, PathDungeonPieces.Piece::new, chunkGeneratorIn, templateManagerIn, posIn, structurePieces, p_215139_4_);
DungeonMod.LOGGER.info("Pieces added");
}
static {
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation(DungeonMod.MOD_ID, "path_dungeon/center"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new SingleJigsawPiece(DungeonMod.MOD_ID + ":path_dungeon/center"), 1)), JigsawPattern.PlacementBehaviour.RIGID));
JigsawManager.REGISTRY.register(new JigsawPattern(new ResourceLocation(DungeonMod.MOD_ID, "path_dungeon/pieces"), new ResourceLocation("empty"), ImmutableList.of(Pair.of(new ListJigsawPiece(ImmutableList.of(new SingleJigsawPiece(DungeonMod.MOD_ID + ":path_dungeon/path_straight"), new SingleJigsawPiece(DungeonMod.MOD_ID + ":path_dungeon/path_turn_right"), new SingleJigsawPiece(DungeonMod.MOD_ID + ":path_dungeon/path_turn_left"), new SingleJigsawPiece(DungeonMod.MOD_ID + ":path_dungeon/path_end"))), 1)), JigsawPattern.PlacementBehaviour.RIGID));
}
public static class Piece extends AbstractVillagePiece {
public Piece(TemplateManager templateManagerIn, JigsawPiece jigsawPieceIn, BlockPos posIn, int p_i50560_4_, Rotation rotationIn, MutableBoundingBox boundsIn) {
super(FeatureInit.PATH_DUNGEON_PIECE, templateManagerIn, jigsawPieceIn, posIn, p_i50560_4_, rotationIn, boundsIn);
}
public Piece(TemplateManager templateManagerIn, CompoundNBT nbt) {
super(templateManagerIn, nbt, FeatureInit.PATH_DUNGEON_PIECE);
}
}
}
And here's my feature init class:
@Mod.EventBusSubscriber(bus = Bus.MOD, modid = DungeonMod.MOD_ID)
public class FeatureInit {
public static final DeferredRegister<Feature<?>> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, DungeonMod.MOD_ID);
public static IStructurePieceType PATH_DUNGEON_PIECE = PathDungeonPieces.Piece::new;
public static final RegistryObject<PathDungeon> PATH_DUNGEON = FEATURES.register("path_dungeon", () -> new PathDungeon(NoFeatureConfig::deserialize));
@SubscribeEvent
public static void registerStructurePieces(RegistryEvent.Register<Feature<?>> event) {
Registry.register(Registry.STRUCTURE_PIECE, "path_dungeon", PATH_DUNGEON_PIECE);
}
}
And here's my package folder for my dungeon pieces:
I have my code and Jigsaw blocks set up exactly how I see other mods/vanilla structures have it. Is there something I'm doing wrong here?