|
11 | 11 | import net.minecraft.core.Direction;
|
12 | 12 | import net.minecraft.resources.ResourceLocation;
|
13 | 13 | import net.minecraft.tags.BlockTags;
|
| 14 | +import net.minecraft.tags.TagKey; |
14 | 15 | import net.minecraft.util.RandomSource;
|
15 | 16 | import net.minecraft.world.level.ChunkPos;
|
16 | 17 | import net.minecraft.world.level.LevelAccessor;
|
|
35 | 36 | import java.util.stream.Stream;
|
36 | 37 |
|
37 | 38 | public abstract class WorldGenDragonCave extends Feature<NoneFeatureConfiguration> {
|
38 |
| - |
39 | 39 | public ResourceLocation DRAGON_CHEST;
|
40 | 40 | public ResourceLocation DRAGON_MALE_CHEST;
|
41 | 41 | public WorldGenCaveStalactites CEILING_DECO;
|
42 | 42 | public BlockState PALETTE_BLOCK1;
|
43 | 43 | public BlockState PALETTE_BLOCK2;
|
44 |
| - public BlockState PALETTE_ORE1; |
45 |
| - public BlockState PALETTE_ORE2; |
| 44 | + public TagKey<Block> dragonTypeOreTag; |
46 | 45 | public BlockState TREASURE_PILE;
|
47 | 46 | private static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
48 | 47 | public boolean isMale;
|
49 |
| - public boolean generateGemOre = false; |
50 | 48 |
|
51 | 49 | protected WorldGenDragonCave(Codec<NoneFeatureConfiguration> codec) {
|
52 | 50 | super(codec);
|
@@ -122,28 +120,28 @@ public void createShell(LevelAccessor worldIn, RandomSource rand, Set<BlockPos>
|
122 | 120 | List<Block> rareOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_RARE_ORES).stream().toList();
|
123 | 121 | List<Block> uncommonOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_UNCOMMON_ORES).stream().toList();
|
124 | 122 | List<Block> commonOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_COMMON_ORES).stream().toList();
|
| 123 | + List<Block> dragonTypeOres = ForgeRegistries.BLOCKS.tags().getTag(dragonTypeOreTag).stream().toList(); |
125 | 124 |
|
126 | 125 | positions.forEach(blockPos -> {
|
127 | 126 | if (!(worldIn.getBlockState(blockPos).getBlock() instanceof BaseEntityBlock) && worldIn.getBlockState(blockPos).getDestroySpeed(worldIn, blockPos) >= 0) {
|
128 | 127 | boolean doOres = rand.nextInt(IafConfig.oreToStoneRatioForDragonCaves + 1) == 0;
|
129 | 128 |
|
130 | 129 | if (doOres) {
|
131 | 130 | int chance = rand.nextInt(199) + 1;
|
132 |
| - BlockState toPlace; |
| 131 | + Block toPlace; |
133 | 132 |
|
134 | 133 | if (chance < 15) {
|
135 |
| - toPlace = rareOres.get(rand.nextInt(rareOres.size())).defaultBlockState(); |
| 134 | + toPlace = rareOres.get(rand.nextInt(rareOres.size())); |
136 | 135 | } else if (chance < 45) {
|
137 |
| - toPlace = uncommonOres.get(rand.nextInt(rareOres.size())).defaultBlockState(); |
| 136 | + toPlace = uncommonOres.get(rand.nextInt(rareOres.size())); |
138 | 137 | } else if (chance < 90) {
|
139 |
| - toPlace = commonOres.get(rand.nextInt(rareOres.size())).defaultBlockState(); |
| 138 | + toPlace = commonOres.get(rand.nextInt(rareOres.size())); |
140 | 139 | } else {
|
141 |
| - toPlace = generateGemOre ? PALETTE_ORE1 : PALETTE_ORE2; |
| 140 | + toPlace = dragonTypeOres.get(rand.nextInt(dragonTypeOres.size())); |
142 | 141 | }
|
143 | 142 |
|
144 |
| - worldIn.setBlock(blockPos, toPlace, Block.UPDATE_CLIENTS); |
| 143 | + worldIn.setBlock(blockPos, toPlace.defaultBlockState(), Block.UPDATE_CLIENTS); |
145 | 144 | } else {
|
146 |
| - // TODO :: Also replace with tags? |
147 | 145 | worldIn.setBlock(blockPos, rand.nextBoolean() ? PALETTE_BLOCK1 : PALETTE_BLOCK2, Block.UPDATE_CLIENTS);
|
148 | 146 | }
|
149 | 147 | }
|
|
0 commit comments