Skip to content

Commit e6a0082

Browse files
SiverDXTheBv
authored andcommitted
feat: more datagen and dragon cave adjustments
- make dragon type specific ore placement configurable
1 parent 4cef3eb commit e6a0082

File tree

21 files changed

+121
-34
lines changed

21 files changed

+121
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"iceandfire:deepslate_silver_ore"
4+
]
5+
}

src/main/resources/data/forge/tags/blocks/ores.json renamed to src/generated/resources/data/forge/tags/blocks/ores.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"replace": false,
32
"values": [
43
"iceandfire:silver_ore",
54
"iceandfire:deepslate_silver_ore",

src/main/resources/data/forge/tags/blocks/ores/silver.json renamed to src/generated/resources/data/forge/tags/blocks/ores/silver.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"replace": false,
32
"values": [
43
"iceandfire:silver_ore",
54
"iceandfire:deepslate_silver_ore"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"values": [
3+
"iceandfire:silver_ore",
4+
"iceandfire:sapphire_ore"
5+
]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"iceandfire:copper_ingot"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"iceandfire:silver_ingot"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"values": [
33
"iceandfire:silver_ore",
4-
"iceandfire:sapphire_ore",
5-
"iceandfire:deepslate_silver_ore"
4+
"iceandfire:deepslate_silver_ore",
5+
"iceandfire:sapphire_ore"
66
]
77
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"values": [
3-
"iceandfire:silver_ore"
3+
"iceandfire:silver_ore",
4+
"iceandfire:deepslate_silver_ore"
45
]
56
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"minecraft:emerald_ore"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"iceandfire:sapphire_ore"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"minecraft:budding_amethyst"
4+
]
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"values": [
3+
"iceandfire:sapphire_ore",
4+
"iceandfire:sapphire_block"
5+
]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"values": [
3+
"iceandfire:silver_ore",
4+
"iceandfire:deepslate_silver_ore",
5+
"iceandfire:silver_block"
6+
]
7+
}

src/main/resources/data/minecraft/tags/items/arrows.json renamed to src/generated/resources/data/minecraft/tags/items/arrows.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"replace": false,
32
"values": [
3+
"iceandfire:dragonbone_arrow",
44
"iceandfire:stymphalian_arrow",
55
"iceandfire:amphithere_arrow",
66
"iceandfire:sea_serpent_arrow",

src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafBlockTags.java

+40
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import net.minecraft.core.registries.Registries;
77
import net.minecraft.data.PackOutput;
88
import net.minecraft.resources.ResourceLocation;
9+
import net.minecraft.tags.BlockTags;
910
import net.minecraft.tags.TagKey;
1011
import net.minecraft.world.level.block.Block;
1112
import net.minecraft.world.level.block.Blocks;
13+
import net.minecraftforge.common.Tags;
1214
import net.minecraftforge.common.data.BlockTagsProvider;
1315
import net.minecraftforge.common.data.ExistingFileHelper;
1416

@@ -21,6 +23,10 @@ public class IafBlockTags extends BlockTagsProvider {
2123
public static TagKey<Block> DRAGON_CAVE_UNCOMMON_ORES = createKey("dragon_cave_uncommon_ores");
2224
public static TagKey<Block> DRAGON_CAVE_COMMON_ORES = createKey("dragon_cave_common_ores");
2325

26+
public static TagKey<Block> FIRE_DRAGON_CAVE_ORES = createKey("fire_dragon_cave_ores");
27+
public static TagKey<Block> ICE_DRAGON_CAVE_ORES = createKey("ice_dragon_cave_ores");
28+
public static TagKey<Block> LIGHTNING_DRAGON_CAVE_ORES = createKey("lightning_dragon_cave_ores");
29+
2430
public IafBlockTags(PackOutput output, CompletableFuture<HolderLookup.Provider> future, ExistingFileHelper helper) {
2531
super(output, future, IceAndFire.MODID, helper);
2632
}
@@ -61,6 +67,40 @@ protected void addTags(HolderLookup.Provider pProvider) {
6167
.add(Blocks.COAL_ORE)
6268
.add(Blocks.COPPER_ORE)
6369
.add(Blocks.IRON_ORE);
70+
71+
tag(FIRE_DRAGON_CAVE_ORES)
72+
.add(Blocks.EMERALD_ORE);
73+
74+
tag(ICE_DRAGON_CAVE_ORES)
75+
.add(IafBlockRegistry.SAPPHIRE_ORE.get());
76+
77+
tag(LIGHTNING_DRAGON_CAVE_ORES)
78+
.add(Blocks.BUDDING_AMETHYST);
79+
80+
tag(BlockTags.NEEDS_STONE_TOOL)
81+
.add(IafBlockRegistry.SILVER_ORE.get())
82+
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get())
83+
.add(IafBlockRegistry.SILVER_BLOCK.get());
84+
85+
tag(BlockTags.NEEDS_IRON_TOOL)
86+
.add(IafBlockRegistry.SAPPHIRE_ORE.get())
87+
.add(IafBlockRegistry.SAPPHIRE_BLOCK.get());
88+
89+
tag(Tags.Blocks.ORES)
90+
.add(IafBlockRegistry.SILVER_ORE.get())
91+
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get())
92+
.add(IafBlockRegistry.SAPPHIRE_ORE.get());
93+
94+
tag(Tags.Blocks.ORES_IN_GROUND_STONE)
95+
.add(IafBlockRegistry.SILVER_ORE.get())
96+
.add(IafBlockRegistry.SAPPHIRE_ORE.get());
97+
98+
tag(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE)
99+
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get());
100+
101+
// These are also used / created by other mods
102+
tag(TagKey.create(Registries.BLOCK, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.SILVER_ORE.get());
103+
tag(TagKey.create(Registries.BLOCK, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get());
64104
}
65105

66106
private static TagKey<Block> createKey(final String name) {

src/main/java/com/github/alexthe666/iceandfire/datagen/tags/IafItemTags.java

+12-7
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ protected void addTags(HolderLookup.Provider provider) {
5050

5151
tag(Tags.Items.ORES)
5252
.add(IafBlockRegistry.SILVER_ORE.get().asItem())
53-
.add(IafBlockRegistry.SAPPHIRE_ORE.get().asItem())
54-
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem());
53+
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem())
54+
.add(IafBlockRegistry.SAPPHIRE_ORE.get().asItem());
5555

5656
tag(Tags.Items.GEMS)
5757
.add(IafItemRegistry.SAPPHIRE_GEM.get());
@@ -126,6 +126,8 @@ protected void addTags(HolderLookup.Provider provider) {
126126

127127
if (item instanceof ItemSeaSerpentScales) {
128128
tag(seaSerpentScales).add(item);
129+
} else if (item instanceof ArrowItem) {
130+
tag(ItemTags.ARROWS).add(item);
129131
} else if (item instanceof SwordItem) {
130132
tag(Tags.Items.TOOLS).add(item);
131133
} else if (item instanceof PickaxeItem) {
@@ -143,11 +145,11 @@ protected void addTags(HolderLookup.Provider provider) {
143145
} else if (item instanceof ArmorItem armorItem) {
144146
tag(Tags.Items.ARMORS).add(item);
145147

146-
switch (armorItem.getSlot()) {
147-
case HEAD -> tag(Tags.Items.ARMORS_HELMETS).add(item);
148-
case CHEST -> tag(Tags.Items.ARMORS_CHESTPLATES).add(item);
149-
case LEGS -> tag(Tags.Items.ARMORS_LEGGINGS).add(item);
150-
case FEET -> tag(Tags.Items.ARMORS_BOOTS).add(item);
148+
switch (armorItem.getType()) {
149+
case HELMET -> tag(Tags.Items.ARMORS_HELMETS).add(item);
150+
case CHESTPLATE -> tag(Tags.Items.ARMORS_CHESTPLATES).add(item);
151+
case LEGGINGS -> tag(Tags.Items.ARMORS_LEGGINGS).add(item);
152+
case BOOTS -> tag(Tags.Items.ARMORS_BOOTS).add(item);
151153
}
152154
}
153155

@@ -158,6 +160,9 @@ protected void addTags(HolderLookup.Provider provider) {
158160

159161
// These are also used / created by other mods
160162
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.SILVER_ORE.get().asItem());
163+
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem());
164+
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ingots/copper"))).add(IafItemRegistry.COPPER_INGOT.get().asItem());
165+
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ingots/silver"))).add(IafItemRegistry.SILVER_INGOT.get().asItem());
161166
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "nuggets/copper"))).add(IafItemRegistry.COPPER_NUGGET.get());
162167
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "nuggets/silver"))).add(IafItemRegistry.SILVER_NUGGET.get());
163168
}

src/main/java/com/github/alexthe666/iceandfire/world/gen/WorldGenDragonCave.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.minecraft.core.Direction;
1212
import net.minecraft.resources.ResourceLocation;
1313
import net.minecraft.tags.BlockTags;
14+
import net.minecraft.tags.TagKey;
1415
import net.minecraft.util.RandomSource;
1516
import net.minecraft.world.level.ChunkPos;
1617
import net.minecraft.world.level.LevelAccessor;
@@ -35,18 +36,15 @@
3536
import java.util.stream.Stream;
3637

3738
public abstract class WorldGenDragonCave extends Feature<NoneFeatureConfiguration> {
38-
3939
public ResourceLocation DRAGON_CHEST;
4040
public ResourceLocation DRAGON_MALE_CHEST;
4141
public WorldGenCaveStalactites CEILING_DECO;
4242
public BlockState PALETTE_BLOCK1;
4343
public BlockState PALETTE_BLOCK2;
44-
public BlockState PALETTE_ORE1;
45-
public BlockState PALETTE_ORE2;
44+
public TagKey<Block> dragonTypeOreTag;
4645
public BlockState TREASURE_PILE;
4746
private static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
4847
public boolean isMale;
49-
public boolean generateGemOre = false;
5048

5149
protected WorldGenDragonCave(Codec<NoneFeatureConfiguration> codec) {
5250
super(codec);
@@ -122,28 +120,28 @@ public void createShell(LevelAccessor worldIn, RandomSource rand, Set<BlockPos>
122120
List<Block> rareOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_RARE_ORES).stream().toList();
123121
List<Block> uncommonOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_UNCOMMON_ORES).stream().toList();
124122
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();
125124

126125
positions.forEach(blockPos -> {
127126
if (!(worldIn.getBlockState(blockPos).getBlock() instanceof BaseEntityBlock) && worldIn.getBlockState(blockPos).getDestroySpeed(worldIn, blockPos) >= 0) {
128127
boolean doOres = rand.nextInt(IafConfig.oreToStoneRatioForDragonCaves + 1) == 0;
129128

130129
if (doOres) {
131130
int chance = rand.nextInt(199) + 1;
132-
BlockState toPlace;
131+
Block toPlace;
133132

134133
if (chance < 15) {
135-
toPlace = rareOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
134+
toPlace = rareOres.get(rand.nextInt(rareOres.size()));
136135
} else if (chance < 45) {
137-
toPlace = uncommonOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
136+
toPlace = uncommonOres.get(rand.nextInt(rareOres.size()));
138137
} else if (chance < 90) {
139-
toPlace = commonOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
138+
toPlace = commonOres.get(rand.nextInt(rareOres.size()));
140139
} else {
141-
toPlace = generateGemOre ? PALETTE_ORE1 : PALETTE_ORE2;
140+
toPlace = dragonTypeOres.get(rand.nextInt(dragonTypeOres.size()));
142141
}
143142

144-
worldIn.setBlock(blockPos, toPlace, Block.UPDATE_CLIENTS);
143+
worldIn.setBlock(blockPos, toPlace.defaultBlockState(), Block.UPDATE_CLIENTS);
145144
} else {
146-
// TODO :: Also replace with tags?
147145
worldIn.setBlock(blockPos, rand.nextBoolean() ? PALETTE_BLOCK1 : PALETTE_BLOCK2, Block.UPDATE_CLIENTS);
148146
}
149147
}

src/main/java/com/github/alexthe666/iceandfire/world/gen/WorldGenFireDragonCave.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.alexthe666.iceandfire.IceAndFire;
44
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
5+
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
56
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
67
import com.github.alexthe666.iceandfire.entity.EntityFireDragon;
78
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
@@ -27,9 +28,7 @@ public WorldGenFireDragonCave(Codec<NoneFeatureConfiguration> configFactoryIn) {
2728
PALETTE_BLOCK1 = IafBlockRegistry.CHARRED_STONE.get().defaultBlockState();
2829
PALETTE_BLOCK2 = IafBlockRegistry.CHARRED_COBBLESTONE.get().defaultBlockState();
2930
TREASURE_PILE = IafBlockRegistry.GOLD_PILE.get().defaultBlockState();
30-
PALETTE_ORE1 = Blocks.EMERALD_ORE.defaultBlockState();
31-
PALETTE_ORE2 = Blocks.EMERALD_ORE.defaultBlockState();
32-
generateGemOre = true;
31+
dragonTypeOreTag = IafBlockTags.FIRE_DRAGON_CAVE_ORES;
3332
}
3433

3534
@Override

src/main/java/com/github/alexthe666/iceandfire/world/gen/WorldGenHydraCave.java

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
124124
}
125125
if (rand.nextInt(45) == 0 && isTouchingAir(worldIn, blockpos.above())) {
126126
worldIn.setBlock(blockpos.above(), Blocks.SKELETON_SKULL.defaultBlockState().setValue(SkullBlock.ROTATION, rand.nextInt(15)), 2);
127-
BlockEntity tileentity1 = worldIn.getBlockEntity(blockpos.above(1));
128127
continue;
129128
}
130129
if (rand.nextInt(35) == 0 && isTouchingAir(worldIn, blockpos.above())) {

src/main/java/com/github/alexthe666/iceandfire/world/gen/WorldGenIceDragonCave.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.alexthe666.iceandfire.IceAndFire;
44
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
5+
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
56
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
67
import com.github.alexthe666.iceandfire.entity.EntityIceDragon;
78
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
@@ -28,9 +29,7 @@ public WorldGenIceDragonCave(Codec<NoneFeatureConfiguration> codec) {
2829
PALETTE_BLOCK1 = IafBlockRegistry.FROZEN_STONE.get().defaultBlockState();
2930
PALETTE_BLOCK2 = IafBlockRegistry.FROZEN_COBBLESTONE.get().defaultBlockState();
3031
TREASURE_PILE = IafBlockRegistry.SILVER_PILE.get().defaultBlockState();
31-
PALETTE_ORE1 = IafBlockRegistry.SAPPHIRE_ORE.get().defaultBlockState();
32-
PALETTE_ORE2 = Blocks.EMERALD_ORE.defaultBlockState();
33-
generateGemOre = true;
32+
dragonTypeOreTag = IafBlockTags.ICE_DRAGON_CAVE_ORES;
3433
}
3534

3635
@Override

src/main/java/com/github/alexthe666/iceandfire/world/gen/WorldGenLightningDragonCave.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.alexthe666.iceandfire.IceAndFire;
44
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
5+
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
56
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
67
import com.github.alexthe666.iceandfire.entity.EntityLightningDragon;
78
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
@@ -27,9 +28,7 @@ public WorldGenLightningDragonCave(Codec<NoneFeatureConfiguration> configFactory
2728
PALETTE_BLOCK1 = IafBlockRegistry.CRACKLED_STONE.get().defaultBlockState();
2829
PALETTE_BLOCK2 = IafBlockRegistry.CRACKLED_COBBLESTONE.get().defaultBlockState();
2930
TREASURE_PILE = IafBlockRegistry.COPPER_PILE.get().defaultBlockState();
30-
PALETTE_ORE1 = Blocks.BUDDING_AMETHYST.defaultBlockState();
31-
PALETTE_ORE2 = IafBlockRegistry.CRACKLED_STONE.get().defaultBlockState();
32-
generateGemOre = true;
31+
dragonTypeOreTag = IafBlockTags.LIGHTNING_DRAGON_CAVE_ORES;
3332
}
3433

3534
@Override

0 commit comments

Comments
 (0)