Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Aug 30, 2023
1 parent b245d07 commit c9701fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ public RailcraftDatapackProvider(PackOutput output,
CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(output, lookupProvider, BUILDER, Set.of(Railcraft.ID));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected Optional<GenerationStub> findGenerationPoint(GenerationContext context
int x = context.chunkPos().getBlockX(9);
int z = context.chunkPos().getBlockZ(9);

for(var holder : context.biomeSource().getBiomesWithin(x,
context.chunkGenerator().getSeaLevel(),z, 29, context.randomState().sampler())) {
for (var holder : context.biomeSource().getBiomesWithin(x,
context.chunkGenerator().getSeaLevel(), z, 29, context.randomState().sampler())) {
if (!holder.is(BiomeTags.IS_DEEP_OCEAN)) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public GeodeStructurePiece(int minX, int y, int minZ) {
this.setOrientation(null);
}

private static BoundingBox createBoundingBox(int minX, int y, int minZ) {
return new BoundingBox(minX, y, minZ, minX + 16, y + 16, minZ + 16);
}

public GeodeStructurePiece(CompoundTag tag) {
super(RailcraftStructurePieces.GEODE.get(), tag);
}

private static BoundingBox createBoundingBox(int minX, int y, int minZ) {
return new BoundingBox(minX, y, minZ, minX + 16, y + 16, minZ + 16);
}

@Override
protected void addAdditionalSaveData(StructurePieceSerializationContext context,
CompoundTag tag) {
Expand Down Expand Up @@ -62,21 +62,17 @@ public void postProcess(WorldGenLevel level, StructureManager structureManager,
}

private void placeAir(WorldGenLevel level, BlockPos pos) {
if (this.canBeReplaced(level, pos.getX(), pos.getY(), pos.getZ(), new BoundingBox(pos))) {
this.placeBlock(level, Blocks.AIR.defaultBlockState(), pos.getX(), pos.getY(), pos.getZ(),
new BoundingBox(pos));
}
this.placeBlock(level, Blocks.AIR.defaultBlockState(), pos.getX(), pos.getY(), pos.getZ(),
this.getBoundingBox());
}

private void placeStone(WorldGenLevel level, BlockPos pos, RandomSource random) {
if (this.canBeReplaced(level, pos.getX(), pos.getY(), pos.getZ(), new BoundingBox(pos))) {
var state = random.nextDouble() < 0.2
? random.nextDouble() < 0.5
? Blocks.DEEPSLATE.defaultBlockState()
: Blocks.SMOOTH_BASALT.defaultBlockState()
: RailcraftBlocks.ABYSSAL_STONE.get().defaultBlockState();
this.placeBlock(level, state, pos.getX(), pos.getY(), pos.getZ(), new BoundingBox(pos));
}
var state = random.nextDouble() < 0.2
? random.nextDouble() < 0.5
? Blocks.DEEPSLATE.defaultBlockState()
: Blocks.SMOOTH_BASALT.defaultBlockState()
: RailcraftBlocks.ABYSSAL_STONE.get().defaultBlockState();
this.placeBlock(level, state, pos.getX(), pos.getY(), pos.getZ(), this.getBoundingBox());
}

private void placeOre(WorldGenLevel level, BlockState existingState, RandomSource random,
Expand All @@ -92,7 +88,7 @@ private void placeOre(WorldGenLevel level, BlockState existingState, RandomSourc
oreState = Blocks.DEEPSLATE_LAPIS_ORE.defaultBlockState();
}
if (oreState != null) {
this.placeBlock(level, oreState, pos.getX(), pos.getY(), pos.getZ(), new BoundingBox(pos));
this.placeBlock(level, oreState, pos.getX(), pos.getY(), pos.getZ(), this.getBoundingBox());
}
}
}
Expand Down

0 comments on commit c9701fd

Please sign in to comment.