Format codes

This commit is contained in:
Snownee 2021-02-06 04:21:07 +08:00
parent 2baa3f9922
commit 25daf28205

View file

@ -23,8 +23,9 @@ public class SchematicProcessor extends StructureProcessor {
public static final SchematicProcessor INSTANCE = new SchematicProcessor(); public static final SchematicProcessor INSTANCE = new SchematicProcessor();
@Nullable @Nullable
@Override @Override
public Template.BlockInfo process(IWorldReader world, BlockPos pos, Template.BlockInfo rawInfo, Template.BlockInfo info, PlacementSettings settings, @Nullable Template template) { public Template.BlockInfo process(IWorldReader world, BlockPos pos, Template.BlockInfo rawInfo,
Template.BlockInfo info, PlacementSettings settings, @Nullable Template template) {
if (info.nbt != null) { if (info.nbt != null) {
TileEntity te = info.state.createTileEntity(world); TileEntity te = info.state.createTileEntity(world);
if (te != null) { if (te != null) {
@ -33,26 +34,25 @@ public class SchematicProcessor extends StructureProcessor {
return new Template.BlockInfo(info.pos, info.state, nbt); return new Template.BlockInfo(info.pos, info.state, nbt);
} }
} }
return info; return info;
} }
@Nullable @Nullable
@Override @Override
public Template.EntityInfo processEntity(IWorldReader world, BlockPos pos, Template.EntityInfo rawInfo, Template.EntityInfo info, PlacementSettings settings, Template template) { public Template.EntityInfo processEntity(IWorldReader world, BlockPos pos, Template.EntityInfo rawInfo,
return EntityType.readEntityType(info.nbt) Template.EntityInfo info, PlacementSettings settings, Template template) {
.flatMap(type -> { return EntityType.readEntityType(info.nbt).flatMap(type -> {
if (world instanceof World) { if (world instanceof World) {
Entity e = type.create((World) world); Entity e = type.create((World) world);
if (e != null && !e.ignoreItemEntityData()) { if (e != null && !e.ignoreItemEntityData()) {
return Optional.of(info); return Optional.of(info);
}
} }
return Optional.empty(); }
}) return Optional.empty();
.orElse(null); }).orElse(null);
} }
@Override @Override
protected IStructureProcessorType getType() { protected IStructureProcessorType getType() {
return dynamic -> INSTANCE; return dynamic -> INSTANCE;
} }