Skip to content

Commit

Permalink
fix tags
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Dec 11, 2024
1 parent 4af11f2 commit 12227c5
Show file tree
Hide file tree
Showing 40 changed files with 71 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.Optional;

public class GenerationConstant {
public class GenerationConstants {
public static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};

public static boolean isFarEnoughFromSpawn(final BlockPos position) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.entity.EntityDeathWorm;
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import net.minecraft.entity.SpawnReason;
import net.minecraft.util.math.BlockPos;
Expand All @@ -26,7 +26,7 @@ public boolean generate(FeatureContext<DefaultFeatureConfig> context) {
BlockPos position = context.getOrigin();
position = worldIn.getTopPosition(Heightmap.Type.WORLD_SURFACE_WG, position.add(8, 0, 8));

if (GenerationConstant.isFarEnoughFromSpawn(position)) {
if (GenerationConstants.isFarEnoughFromSpawn(position)) {
if (rand.nextDouble() < IafCommonConfig.INSTANCE.deathworm.spawnChance.getValue()) {
EntityDeathWorm deathWorm = IafEntities.DEATH_WORM.get().create(worldIn.toServerWorld());
assert deathWorm != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.entity.EntitySeaSerpent;
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import net.minecraft.fluid.Fluids;
import net.minecraft.util.math.BlockPos;
Expand All @@ -28,7 +28,7 @@ public boolean generate(FeatureContext<DefaultFeatureConfig> context) {
position = worldIn.getTopPosition(Heightmap.Type.WORLD_SURFACE_WG, position.add(8, 0, 8));
BlockPos oceanPos = worldIn.getTopPosition(Heightmap.Type.OCEAN_FLOOR_WG, position.add(8, 0, 8));

if (GenerationConstant.isFarEnoughFromSpawn(position)) {
if (GenerationConstants.isFarEnoughFromSpawn(position)) {
if (rand.nextDouble() < IafCommonConfig.INSTANCE.seaSerpent.spawnChance.getValue()) {
BlockPos pos = oceanPos.add(rand.nextInt(10) - 5, rand.nextInt(30), rand.nextInt(10) - 5);
if (worldIn.getFluidState(pos).getFluid() == Fluids.WATER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.entity.EntityStymphalianBird;
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
Expand All @@ -26,7 +26,7 @@ public boolean generate(FeatureContext<DefaultFeatureConfig> context) {

position = worldIn.getTopPosition(Heightmap.Type.WORLD_SURFACE_WG, position.add(8, 0, 8));

if (GenerationConstant.isFarEnoughFromSpawn(position)) {
if (GenerationConstants.isFarEnoughFromSpawn(position)) {
if (rand.nextDouble() < IafCommonConfig.INSTANCE.stymphalianBird.spawnChance.getValue())
for (int i = 0; i < 4 + rand.nextInt(4); i++) {
BlockPos pos = position.add(rand.nextInt(10) - 5, 0, rand.nextInt(10) - 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.entity.EntityCyclops;
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
Expand All @@ -29,7 +29,7 @@ public boolean generate(FeatureContext<DefaultFeatureConfig> context) {

position = worldIn.getTopPosition(Heightmap.Type.WORLD_SURFACE_WG, position.add(8, 0, 8));

if (GenerationConstant.isFarEnoughFromSpawn(position)) {
if (GenerationConstants.isFarEnoughFromSpawn(position)) {
if (rand.nextDouble() < IafCommonConfig.INSTANCE.cyclops.spawnWanderingChance.getValue() && rand.nextInt(12) == 0) {
EntityCyclops cyclops = IafEntities.CYCLOPS.get().create(worldIn.toServerWorld());
assert cyclops != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.registry.IafStructurePieces;
import com.iafenvoy.iceandfire.registry.IafStructureTypes;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.*;
Expand Down Expand Up @@ -49,7 +49,7 @@ protected CyclopsCaveStructure(Config config) {
protected Optional<StructurePosition> getStructurePosition(Context context) {
BlockRotation blockRotation = BlockRotation.random(context.random());
BlockPos blockPos = this.getShiftedPos(context, blockRotation);
if (!GenerationConstant.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
return Optional.of(new StructurePosition(blockPos, collector -> collector.addPiece(new CyclopsCavePiece(0, new BlockBox(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX(), blockPos.getY(), blockPos.getZ())))));
}

Expand Down Expand Up @@ -108,7 +108,7 @@ public void generate(StructureWorldAccess world, StructureAccessor structureAcce
world.setBlockState(position.up().south(), IafBlocks.GOLD_PILE.get().getDefaultState().with(BlockGoldPile.LAYERS, 1 + new java.util.Random().nextInt(7)), 3);
world.setBlockState(position.up().west(), IafBlocks.GOLD_PILE.get().getDefaultState().with(BlockGoldPile.LAYERS, 1 + new java.util.Random().nextInt(7)), 3);
world.setBlockState(position.up().east(), IafBlocks.GOLD_PILE.get().getDefaultState().with(BlockGoldPile.LAYERS, 1 + new java.util.Random().nextInt(7)), 3);
world.setBlockState(position.up(2), Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstant.HORIZONTALS[new java.util.Random().nextInt(3)]), 2);
world.setBlockState(position.up(2), Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstants.HORIZONTALS[new java.util.Random().nextInt(3)]), 2);

if (world.getBlockState(position.up(2)).getBlock() instanceof AbstractChestBlock) {
BlockEntity blockEntity = world.getBlockEntity(position.up(2));
Expand Down Expand Up @@ -173,7 +173,7 @@ private void generateSheepPen(ServerWorldAccess level, BlockPos position, Random
}

private void generateSkeleton(WorldAccess level, BlockPos position, Random random, BlockPos origin, float radius) {
Direction direction = GenerationConstant.HORIZONTALS[random.nextInt(3)];
Direction direction = GenerationConstants.HORIZONTALS[random.nextInt(3)];
Direction.Axis oppositeAxis = direction.getAxis() == Direction.Axis.X ? Direction.Axis.Z : Direction.Axis.X;
int maxRibHeight = random.nextInt(2);

Expand Down Expand Up @@ -209,7 +209,7 @@ private void generateSkeleton(WorldAccess level, BlockPos position, Random rando
}

private boolean isTouchingAir(WorldAccess level, BlockPos position) {
for (Direction direction : GenerationConstant.HORIZONTALS)
for (Direction direction : GenerationConstants.HORIZONTALS)
if (!level.isAir(position.offset(direction)))
return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.iafenvoy.iceandfire.entity.util.HomePosition;
import com.iafenvoy.iceandfire.item.block.BlockGoldPile;
import com.iafenvoy.iceandfire.registry.tag.IafBlockTags;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.iafenvoy.uranus.util.ShapeBuilder;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
Expand Down Expand Up @@ -49,7 +49,7 @@ protected DragonCaveStructure(Config config) {
protected Optional<StructurePosition> getStructurePosition(Context context) {
BlockRotation blockRotation = BlockRotation.random(context.random());
BlockPos blockPos = this.getShiftedPos(context, blockRotation);
if (!GenerationConstant.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
return Optional.of(new StructurePosition(blockPos, collector -> this.addPieces(collector, blockPos, context, context.random().nextBoolean())));
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public void generateCave(WorldAccess worldIn, int radius, int amount, BlockPos c
//Get shells
//Get hollows
for (int i = 0; i < amount + rand.nextInt(2); i++) {
Direction direction = GenerationConstant.HORIZONTALS[rand.nextInt(GenerationConstant.HORIZONTALS.length - 1)];
Direction direction = GenerationConstants.HORIZONTALS[rand.nextInt(GenerationConstants.HORIZONTALS.length - 1)];
int r = 2 * (int) (radius / 3F) + rand.nextInt(8);
BlockPos centerOffset = center.offset(direction, radius - 2);
sphereBlocks = Stream.concat(sphereBlocks, ShapeBuilder.start().getAllInCutOffSphereMutable(r, r, centerOffset).toStream(false));
Expand Down Expand Up @@ -211,7 +211,7 @@ public void setGoldPile(WorldAccess world, BlockPos pos, Random rand) {
boolean generateGold = rand.nextDouble() < IafCommonConfig.INSTANCE.dragon.generateDenGoldChance.getValue() * (this.male ? 1 : 2);
world.setBlockState(pos, generateGold ? this.getTreasurePile().with(BlockGoldPile.LAYERS, 1 + rand.nextInt(7)) : Blocks.AIR.getDefaultState(), 3);
} else if (chance == 61) {
world.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstant.HORIZONTALS[rand.nextInt(3)]), Block.NOTIFY_LISTENERS);
world.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstants.HORIZONTALS[rand.nextInt(3)]), Block.NOTIFY_LISTENERS);
if (world.getBlockState(pos).getBlock() instanceof ChestBlock) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof ChestBlockEntity chestBlockEntity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.iafenvoy.iceandfire.entity.EntityDragonBase;
import com.iafenvoy.iceandfire.entity.util.HomePosition;
import com.iafenvoy.iceandfire.item.block.BlockGoldPile;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.ChestBlockEntity;
Expand Down Expand Up @@ -39,7 +39,7 @@ protected DragonRoostStructure(Config config) {
protected Optional<StructurePosition> getStructurePosition(Context context) {
BlockRotation blockRotation = BlockRotation.random(context.random());
BlockPos blockPos = this.getShiftedPos(context, blockRotation);
if (!GenerationConstant.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
return Optional.of(new StructurePosition(blockPos, collector -> collector.addPiece(this.createPiece(new BlockBox(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX(), blockPos.getY(), blockPos.getZ()), context.random().nextBoolean()))));
}

Expand Down Expand Up @@ -142,7 +142,7 @@ private void generateDecoration(StructureWorldAccess world, BlockPos origin, Ran

if (distance < 0.3D && random.nextInt(isMale ? 500 : 700) == 0) {
BlockPos surfacePosition = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, position);
boolean wasPlaced = world.setBlockState(surfacePosition, Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstant.HORIZONTALS[random.nextInt(3)]), Block.NOTIFY_LISTENERS);
boolean wasPlaced = world.setBlockState(surfacePosition, Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstants.HORIZONTALS[random.nextInt(3)]), Block.NOTIFY_LISTENERS);

if (wasPlaced) {
BlockEntity blockEntity = world.getBlockEntity(surfacePosition);
Expand Down Expand Up @@ -189,7 +189,7 @@ public void generateBoulder(WorldAccess worldIn, Random rand, BlockPos position,
private void generateArch(WorldAccess worldIn, Random rand, BlockPos position, Block block) {
int height = 3 + rand.nextInt(3);
int width = Math.min(3, height - 2);
Direction direction = GenerationConstant.HORIZONTALS[rand.nextInt(GenerationConstant.HORIZONTALS.length - 1)];
Direction direction = GenerationConstants.HORIZONTALS[rand.nextInt(GenerationConstants.HORIZONTALS.length - 1)];
boolean diagonal = rand.nextBoolean();
for (int i = 0; i < height; i++)
worldIn.setBlockState(position.up(i), block.getDefaultState(), 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.registry.IafStructureTypes;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.registry.entry.RegistryEntry;
Expand Down Expand Up @@ -39,7 +39,7 @@ protected Optional<StructurePosition> getStructurePosition(Context pContext) {
return Optional.empty();
ChunkPos pos = pContext.chunkPos();
BlockPos blockpos = pos.getCenterAtY(1);
if (!GenerationConstant.isFarEnoughFromSpawn(blockpos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockpos)) return Optional.empty();
return StructurePoolBasedGenerator.generate(
pContext, // Used for JigsawPlacement to get all the proper behaviors done.
this.startPool, // The starting pool to use to create the structure layout from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.iafenvoy.iceandfire.registry.IafEntities;
import com.iafenvoy.iceandfire.registry.IafStructurePieces;
import com.iafenvoy.iceandfire.registry.IafStructureTypes;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -47,7 +47,7 @@ protected HydraCaveStructure(Config config) {
protected Optional<StructurePosition> getStructurePosition(Context context) {
BlockRotation blockRotation = BlockRotation.random(context.random());
BlockPos blockPos = this.getShiftedPos(context, blockRotation);
if (!GenerationConstant.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockPos)) return Optional.empty();
return Optional.of(new StructurePosition(blockPos, collector -> collector.addPiece(new HydraCavePiece(0, new BlockBox(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX(), blockPos.getY(), blockPos.getZ())))));
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public void generate(StructureWorldAccess world, StructureAccessor structureAcce
for (BlockPos blockpos : BlockPos.stream(pivot.add(-j, -k, -l), pivot.add(j, k + 8, l)).map(BlockPos::toImmutable).collect(Collectors.toSet())) {
if (blockpos.getSquaredDistance(pivot) <= f * f && blockpos.getY() == pivot.getY()) {
if (random.nextInt(30) == 0 && this.isTouchingAir(world, blockpos.up())) {
world.setBlockState(blockpos.up(1), Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstant.HORIZONTALS[new java.util.Random().nextInt(3)]), 2);
world.setBlockState(blockpos.up(1), Blocks.CHEST.getDefaultState().with(ChestBlock.FACING, GenerationConstants.HORIZONTALS[new java.util.Random().nextInt(3)]), 2);
if (world.getBlockState(blockpos.up(1)).getBlock() instanceof ChestBlock)
if (world.getBlockEntity(blockpos.up(1)) instanceof ChestBlockEntity chest)
chest.setLootTable(HYDRA_CHEST, random.nextLong());
Expand Down Expand Up @@ -150,7 +150,7 @@ public void generate(StructureWorldAccess world, StructureAccessor structureAcce
}

private boolean isTouchingAir(WorldAccess worldIn, BlockPos pos) {
for (Direction direction : GenerationConstant.HORIZONTALS)
for (Direction direction : GenerationConstants.HORIZONTALS)
if (!worldIn.isAir(pos.offset(direction)))
return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.iafenvoy.iceandfire.registry.IafStructurePieces;
import com.iafenvoy.iceandfire.registry.IafStructureTypes;
import com.iafenvoy.iceandfire.registry.tag.CommonTags;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -95,7 +95,7 @@ protected void handleCustomGeneration(StructureWorldAccess world, BlockPos origi
if (distance > 0.05D && random.nextInt(800) == 0)
this.generateSpire(world, random, this.getSurfacePosition(world, position));
if (distance > 0.05D && random.nextInt(1000) == 0)
this.generateSpike(world, random, this.getSurfacePosition(world, position), GenerationConstant.HORIZONTALS[random.nextInt(3)]);
this.generateSpike(world, random, this.getSurfacePosition(world, position), GenerationConstants.HORIZONTALS[random.nextInt(3)]);
}

private void generateSpike(WorldAccess worldIn, Random rand, BlockPos position, Direction direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.iafenvoy.iceandfire.config.IafCommonConfig;
import com.iafenvoy.iceandfire.registry.IafStructureTypes;
import com.iafenvoy.iceandfire.world.GenerationConstant;
import com.iafenvoy.iceandfire.world.GenerationConstants;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.registry.entry.RegistryEntry;
Expand Down Expand Up @@ -38,7 +38,7 @@ protected Optional<StructurePosition> getStructurePosition(Context pContext) {
return Optional.empty();
ChunkPos pos = pContext.chunkPos();
BlockPos blockpos = pos.getCenterAtY(1);
if (!GenerationConstant.isFarEnoughFromSpawn(blockpos)) return Optional.empty();
if (!GenerationConstants.isFarEnoughFromSpawn(blockpos)) return Optional.empty();
return StructurePoolBasedGenerator.generate(
pContext, // Used for JigsawPlacement to get all the proper behaviors done.
this.startPool, // The starting pool to use to create the structure layout from
Expand Down
Loading

0 comments on commit 12227c5

Please sign in to comment.