use of com.silverminer.shrines.utils.custom_structures.ModTemplateManager in project Shrines by Silverminer007.
the class CustomStructureData method loadPieces.
public boolean loadPieces(ServerWorld serverWorld, MinecraftServer server, BlockPos loadPos, Rotation rot) {
ModTemplateManager templatemanager;
for (PieceData pd : this.pieces.getValue()) {
ResourceLocation location = new ResourceLocation(ShrinesMod.MODID, name + "/" + pd.path);
try {
templatemanager = new ModTemplateManager(Utils.getSaveLocation().getCanonicalFile().toPath(), server.getFixerUpper());
} catch (IOException e) {
e.printStackTrace();
return false;
}
Template template;
try {
template = templatemanager.get(location);
} catch (ResourceLocationException resourcelocationexception) {
return false;
}
if (template == null)
return false;
BlockPos blockpos = loadPos.offset(pd.offset);
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE).setRotation(rot).setIgnoreEntities(false).setChunkPos((ChunkPos) null);
template.placeInWorldChunk(serverWorld, blockpos, placementsettings, createRandom(this.seed.getValue()));
}
return true;
}
use of com.silverminer.shrines.utils.custom_structures.ModTemplateManager in project Shrines by Silverminer007.
the class CustomStructureData method savePieces.
public boolean savePieces(ServerWorld serverWorld, MinecraftServer server, String author, boolean includeEntities) {
ModTemplateManager templatemanager;
try {
templatemanager = new ModTemplateManager(Utils.getSaveLocation().getCanonicalFile().toPath(), server.getFixerUpper());
} catch (IOException e) {
e.printStackTrace();
return false;
}
for (ResourceData rd : PIECES_ON_FLY) {
ResourceLocation location = new ResourceLocation(ShrinesMod.MODID, name + "/" + rd.getName());
MutableBoundingBox mbb = rd.getBounds();
BlockPos c0 = new BlockPos(mbb.x0, mbb.y0, mbb.z0);
BlockPos c1 = new BlockPos(mbb.x1, mbb.y1, mbb.z1);
Template template;
try {
template = templatemanager.getOrCreate(location);
} catch (ResourceLocationException resourcelocationexception) {
LOGGER.error(resourcelocationexception);
return false;
}
template.fillFromWorld(serverWorld, c0, c1.subtract(c0), includeEntities, Blocks.STRUCTURE_VOID);
template.setAuthor(author);
try {
if (!templatemanager.save(location)) {
return false;
}
} catch (ResourceLocationException resourcelocationexception) {
LOGGER.error(resourcelocationexception);
return false;
}
}
return true;
}
Aggregations