Skip to content

Commit

Permalink
feat: more datagen and dragon cave adjustments
Browse files Browse the repository at this point in the history
- make dragon type specific ore placement configurable
  • Loading branch information
SiverDX authored and TheBv committed Dec 26, 2023
1 parent 4cef3eb commit e6a0082
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"iceandfire:deepslate_silver_ore"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"replace": false,
"values": [
"iceandfire:silver_ore",
"iceandfire:deepslate_silver_ore",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"replace": false,
"values": [
"iceandfire:silver_ore",
"iceandfire:deepslate_silver_ore"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"iceandfire:silver_ore",
"iceandfire:sapphire_ore"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"iceandfire:copper_ingot"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"iceandfire:silver_ingot"
]
}
4 changes: 2 additions & 2 deletions src/generated/resources/data/forge/tags/items/ores.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"values": [
"iceandfire:silver_ore",
"iceandfire:sapphire_ore",
"iceandfire:deepslate_silver_ore"
"iceandfire:deepslate_silver_ore",
"iceandfire:sapphire_ore"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"values": [
"iceandfire:silver_ore"
"iceandfire:silver_ore",
"iceandfire:deepslate_silver_ore"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:emerald_ore"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"iceandfire:sapphire_ore"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:budding_amethyst"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"iceandfire:sapphire_ore",
"iceandfire:sapphire_block"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"iceandfire:silver_ore",
"iceandfire:deepslate_silver_ore",
"iceandfire:silver_block"
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"iceandfire:dragonbone_arrow",
"iceandfire:stymphalian_arrow",
"iceandfire:amphithere_arrow",
"iceandfire:sea_serpent_arrow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.BlockTagsProvider;
import net.minecraftforge.common.data.ExistingFileHelper;

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

public static TagKey<Block> FIRE_DRAGON_CAVE_ORES = createKey("fire_dragon_cave_ores");
public static TagKey<Block> ICE_DRAGON_CAVE_ORES = createKey("ice_dragon_cave_ores");
public static TagKey<Block> LIGHTNING_DRAGON_CAVE_ORES = createKey("lightning_dragon_cave_ores");

public IafBlockTags(PackOutput output, CompletableFuture<HolderLookup.Provider> future, ExistingFileHelper helper) {
super(output, future, IceAndFire.MODID, helper);
}
Expand Down Expand Up @@ -61,6 +67,40 @@ protected void addTags(HolderLookup.Provider pProvider) {
.add(Blocks.COAL_ORE)
.add(Blocks.COPPER_ORE)
.add(Blocks.IRON_ORE);

tag(FIRE_DRAGON_CAVE_ORES)
.add(Blocks.EMERALD_ORE);

tag(ICE_DRAGON_CAVE_ORES)
.add(IafBlockRegistry.SAPPHIRE_ORE.get());

tag(LIGHTNING_DRAGON_CAVE_ORES)
.add(Blocks.BUDDING_AMETHYST);

tag(BlockTags.NEEDS_STONE_TOOL)
.add(IafBlockRegistry.SILVER_ORE.get())
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get())
.add(IafBlockRegistry.SILVER_BLOCK.get());

tag(BlockTags.NEEDS_IRON_TOOL)
.add(IafBlockRegistry.SAPPHIRE_ORE.get())
.add(IafBlockRegistry.SAPPHIRE_BLOCK.get());

tag(Tags.Blocks.ORES)
.add(IafBlockRegistry.SILVER_ORE.get())
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get())
.add(IafBlockRegistry.SAPPHIRE_ORE.get());

tag(Tags.Blocks.ORES_IN_GROUND_STONE)
.add(IafBlockRegistry.SILVER_ORE.get())
.add(IafBlockRegistry.SAPPHIRE_ORE.get());

tag(Tags.Blocks.ORE_BEARING_GROUND_DEEPSLATE)
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get());

// These are also used / created by other mods
tag(TagKey.create(Registries.BLOCK, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.SILVER_ORE.get());
tag(TagKey.create(Registries.BLOCK, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get());
}

private static TagKey<Block> createKey(final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ protected void addTags(HolderLookup.Provider provider) {

tag(Tags.Items.ORES)
.add(IafBlockRegistry.SILVER_ORE.get().asItem())
.add(IafBlockRegistry.SAPPHIRE_ORE.get().asItem())
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem());
.add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem())
.add(IafBlockRegistry.SAPPHIRE_ORE.get().asItem());

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

if (item instanceof ItemSeaSerpentScales) {
tag(seaSerpentScales).add(item);
} else if (item instanceof ArrowItem) {
tag(ItemTags.ARROWS).add(item);
} else if (item instanceof SwordItem) {
tag(Tags.Items.TOOLS).add(item);
} else if (item instanceof PickaxeItem) {
Expand All @@ -143,11 +145,11 @@ protected void addTags(HolderLookup.Provider provider) {
} else if (item instanceof ArmorItem armorItem) {
tag(Tags.Items.ARMORS).add(item);

switch (armorItem.getSlot()) {
case HEAD -> tag(Tags.Items.ARMORS_HELMETS).add(item);
case CHEST -> tag(Tags.Items.ARMORS_CHESTPLATES).add(item);
case LEGS -> tag(Tags.Items.ARMORS_LEGGINGS).add(item);
case FEET -> tag(Tags.Items.ARMORS_BOOTS).add(item);
switch (armorItem.getType()) {
case HELMET -> tag(Tags.Items.ARMORS_HELMETS).add(item);
case CHESTPLATE -> tag(Tags.Items.ARMORS_CHESTPLATES).add(item);
case LEGGINGS -> tag(Tags.Items.ARMORS_LEGGINGS).add(item);
case BOOTS -> tag(Tags.Items.ARMORS_BOOTS).add(item);
}
}

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

// These are also used / created by other mods
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.SILVER_ORE.get().asItem());
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ores/silver"))).add(IafBlockRegistry.DEEPSLATE_SILVER_ORE.get().asItem());
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ingots/copper"))).add(IafItemRegistry.COPPER_INGOT.get().asItem());
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "ingots/silver"))).add(IafItemRegistry.SILVER_INGOT.get().asItem());
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "nuggets/copper"))).add(IafItemRegistry.COPPER_NUGGET.get());
tag(TagKey.create(Registries.ITEM, new ResourceLocation("forge", "nuggets/silver"))).add(IafItemRegistry.SILVER_NUGGET.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelAccessor;
Expand All @@ -35,18 +36,15 @@
import java.util.stream.Stream;

public abstract class WorldGenDragonCave extends Feature<NoneFeatureConfiguration> {

public ResourceLocation DRAGON_CHEST;
public ResourceLocation DRAGON_MALE_CHEST;
public WorldGenCaveStalactites CEILING_DECO;
public BlockState PALETTE_BLOCK1;
public BlockState PALETTE_BLOCK2;
public BlockState PALETTE_ORE1;
public BlockState PALETTE_ORE2;
public TagKey<Block> dragonTypeOreTag;
public BlockState TREASURE_PILE;
private static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
public boolean isMale;
public boolean generateGemOre = false;

protected WorldGenDragonCave(Codec<NoneFeatureConfiguration> codec) {
super(codec);
Expand Down Expand Up @@ -122,28 +120,28 @@ public void createShell(LevelAccessor worldIn, RandomSource rand, Set<BlockPos>
List<Block> rareOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_RARE_ORES).stream().toList();
List<Block> uncommonOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_UNCOMMON_ORES).stream().toList();
List<Block> commonOres = ForgeRegistries.BLOCKS.tags().getTag(IafBlockTags.DRAGON_CAVE_COMMON_ORES).stream().toList();
List<Block> dragonTypeOres = ForgeRegistries.BLOCKS.tags().getTag(dragonTypeOreTag).stream().toList();

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

if (doOres) {
int chance = rand.nextInt(199) + 1;
BlockState toPlace;
Block toPlace;

if (chance < 15) {
toPlace = rareOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
toPlace = rareOres.get(rand.nextInt(rareOres.size()));
} else if (chance < 45) {
toPlace = uncommonOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
toPlace = uncommonOres.get(rand.nextInt(rareOres.size()));
} else if (chance < 90) {
toPlace = commonOres.get(rand.nextInt(rareOres.size())).defaultBlockState();
toPlace = commonOres.get(rand.nextInt(rareOres.size()));
} else {
toPlace = generateGemOre ? PALETTE_ORE1 : PALETTE_ORE2;
toPlace = dragonTypeOres.get(rand.nextInt(dragonTypeOres.size()));
}

worldIn.setBlock(blockPos, toPlace, Block.UPDATE_CLIENTS);
worldIn.setBlock(blockPos, toPlace.defaultBlockState(), Block.UPDATE_CLIENTS);
} else {
// TODO :: Also replace with tags?
worldIn.setBlock(blockPos, rand.nextBoolean() ? PALETTE_BLOCK1 : PALETTE_BLOCK2, Block.UPDATE_CLIENTS);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.alexthe666.iceandfire.IceAndFire;
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
import com.github.alexthe666.iceandfire.entity.EntityFireDragon;
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
Expand All @@ -27,9 +28,7 @@ public WorldGenFireDragonCave(Codec<NoneFeatureConfiguration> configFactoryIn) {
PALETTE_BLOCK1 = IafBlockRegistry.CHARRED_STONE.get().defaultBlockState();
PALETTE_BLOCK2 = IafBlockRegistry.CHARRED_COBBLESTONE.get().defaultBlockState();
TREASURE_PILE = IafBlockRegistry.GOLD_PILE.get().defaultBlockState();
PALETTE_ORE1 = Blocks.EMERALD_ORE.defaultBlockState();
PALETTE_ORE2 = Blocks.EMERALD_ORE.defaultBlockState();
generateGemOre = true;
dragonTypeOreTag = IafBlockTags.FIRE_DRAGON_CAVE_ORES;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
}
if (rand.nextInt(45) == 0 && isTouchingAir(worldIn, blockpos.above())) {
worldIn.setBlock(blockpos.above(), Blocks.SKELETON_SKULL.defaultBlockState().setValue(SkullBlock.ROTATION, rand.nextInt(15)), 2);
BlockEntity tileentity1 = worldIn.getBlockEntity(blockpos.above(1));
continue;
}
if (rand.nextInt(35) == 0 && isTouchingAir(worldIn, blockpos.above())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.alexthe666.iceandfire.IceAndFire;
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
import com.github.alexthe666.iceandfire.entity.EntityIceDragon;
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
Expand All @@ -28,9 +29,7 @@ public WorldGenIceDragonCave(Codec<NoneFeatureConfiguration> codec) {
PALETTE_BLOCK1 = IafBlockRegistry.FROZEN_STONE.get().defaultBlockState();
PALETTE_BLOCK2 = IafBlockRegistry.FROZEN_COBBLESTONE.get().defaultBlockState();
TREASURE_PILE = IafBlockRegistry.SILVER_PILE.get().defaultBlockState();
PALETTE_ORE1 = IafBlockRegistry.SAPPHIRE_ORE.get().defaultBlockState();
PALETTE_ORE2 = Blocks.EMERALD_ORE.defaultBlockState();
generateGemOre = true;
dragonTypeOreTag = IafBlockTags.ICE_DRAGON_CAVE_ORES;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.alexthe666.iceandfire.IceAndFire;
import com.github.alexthe666.iceandfire.block.IafBlockRegistry;
import com.github.alexthe666.iceandfire.datagen.tags.IafBlockTags;
import com.github.alexthe666.iceandfire.entity.EntityDragonBase;
import com.github.alexthe666.iceandfire.entity.EntityLightningDragon;
import com.github.alexthe666.iceandfire.entity.IafEntityRegistry;
Expand All @@ -27,9 +28,7 @@ public WorldGenLightningDragonCave(Codec<NoneFeatureConfiguration> configFactory
PALETTE_BLOCK1 = IafBlockRegistry.CRACKLED_STONE.get().defaultBlockState();
PALETTE_BLOCK2 = IafBlockRegistry.CRACKLED_COBBLESTONE.get().defaultBlockState();
TREASURE_PILE = IafBlockRegistry.COPPER_PILE.get().defaultBlockState();
PALETTE_ORE1 = Blocks.BUDDING_AMETHYST.defaultBlockState();
PALETTE_ORE2 = IafBlockRegistry.CRACKLED_STONE.get().defaultBlockState();
generateGemOre = true;
dragonTypeOreTag = IafBlockTags.LIGHTNING_DRAGON_CAVE_ORES;
}

@Override
Expand Down

0 comments on commit e6a0082

Please sign in to comment.