Changement global + ajout item et commande

This commit is contained in:
feldenr
2026-01-04 22:08:42 +01:00
parent 23a8b11147
commit e388fb6ad1
8758 changed files with 442074 additions and 118334 deletions
@@ -0,0 +1,148 @@
package net.mcreator.customoregen;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.biome.Biome;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.util.*;
@Mod.EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class OresCommand {
// Tags personnalisés du mod
private static final TagKey<Biome> COLD_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "cold_biomes"));
private static final TagKey<Biome> HOT_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "hot_biomes"));
private static final TagKey<Biome> MOUNTAIN_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "mountain_biomes"));
private static final TagKey<Biome> TEMPERED_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "tempered_biomes"));
private static final TagKey<Biome> RARE_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "rare_biomes"));
// Minerais par catégorie (mappé avec les biome modifiers)
private static final List<String> COLD_ORES = Arrays.asList(
"Lapis (stone)",
"Lapis (deepslate)",
"Diamant Concentre"
);
private static final List<String> HOT_ORES = Arrays.asList(
"Or Pur (stone)",
"Or Pur (deepslate)",
"Redstone (stone)",
"Redstone (deepslate)",
"Cuivre (haut)",
"Cuivre (bas)"
);
private static final List<String> MOUNTAIN_ORES = Arrays.asList(
"Emeraude (haute altitude)"
);
private static final List<String> TEMPERED_ORES = Arrays.asList(
"Charbon Concentre",
"Fer (stone)",
"Fer (deepslate)"
);
private static final List<String> RARE_ORES = Arrays.asList(
"Emeraude (basse altitude)"
);
private static final List<String> EVERYWHERE_ORES = Arrays.asList(
"Diamant Shard (deepslate)",
"Bloc Diamant Shard"
);
@SubscribeEvent
public static void onRegisterCommands(RegisterCommandsEvent event) {
CommandDispatcher<CommandSourceStack> dispatcher = event.getDispatcher();
dispatcher.register(Commands.literal("ores")
.executes(OresCommand::executeOres)
);
dispatcher.register(Commands.literal("ore")
.executes(OresCommand::executeOres)
);
}
private static int executeOres(CommandContext<CommandSourceStack> context) {
if (!(context.getSource().getEntity() instanceof net.minecraft.world.entity.player.Player)) {
context.getSource().sendFailure(Component.literal("Cette commande ne peut etre utilisee que par un joueur"));
return 0;
}
net.minecraft.world.entity.player.Player player = (net.minecraft.world.entity.player.Player) context.getSource().getEntity();
net.minecraft.world.level.Level level = player.level();
net.minecraft.core.BlockPos pos = player.blockPosition();
var biomeHolder = level.getBiome(pos);
ResourceKey<Biome> biomeKey = biomeHolder.unwrapKey().orElse(ResourceKey.create(Registries.BIOME, new ResourceLocation("minecraft:plains")));
ResourceLocation biomeId = biomeKey.location();
String biomeName = biomeId.getPath();
context.getSource().sendSuccess(() -> Component.literal("=== Minerais dans: " + biomeName + " ==="), true);
context.getSource().sendSuccess(() -> Component.literal("Biome ID: " + biomeId), true);
// Vérifier les tags personnalisés du mod
Set<String> foundTags = new HashSet<>();
List<String> foundOres = new ArrayList<>();
// Vérifier chaque tag de biome et ajouter les minerais correspondants
if (isBiomeInTag(level, pos, COLD_BIOMES_TAG)) {
foundTags.add("cold_biomes");
foundOres.addAll(COLD_ORES);
}
if (isBiomeInTag(level, pos, HOT_BIOMES_TAG)) {
foundTags.add("hot_biomes");
foundOres.addAll(HOT_ORES);
}
if (isBiomeInTag(level, pos, MOUNTAIN_BIOMES_TAG)) {
foundTags.add("mountain_biomes");
foundOres.addAll(MOUNTAIN_ORES);
}
if (isBiomeInTag(level, pos, TEMPERED_BIOMES_TAG)) {
foundTags.add("tempered_biomes");
foundOres.addAll(TEMPERED_ORES);
}
if (isBiomeInTag(level, pos, RARE_BIOMES_TAG)) {
foundTags.add("rare_biomes");
foundOres.addAll(RARE_ORES);
}
// Ajouter les minerais présents partout
foundOres.addAll(EVERYWHERE_ORES);
// Afficher les tags trouvés
if (!foundTags.isEmpty()) {
context.getSource().sendSuccess(() -> Component.literal("Tags du mod: " + String.join(", ", foundTags)), true);
} else {
context.getSource().sendSuccess(() -> Component.literal("Tags du mod: aucun"), true);
}
// Afficher les minerais (sans doublons)
if (!foundOres.isEmpty()) {
Set<String> uniqueOres = new LinkedHashSet<>(foundOres);
context.getSource().sendSuccess(() -> Component.literal("Minerais trouvables:"), true);
for (String ore : uniqueOres) {
context.getSource().sendSuccess(() -> Component.literal(" * " + ore), true);
}
} else {
context.getSource().sendSuccess(() -> Component.literal("Aucun minerai specifique"), true);
}
return 1;
}
private static boolean isBiomeInTag(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, TagKey<Biome> tag) {
return level.getBiome(pos).is(tag);
}
}
@@ -16,6 +16,7 @@ import net.mcreator.customoregen.item.SharddiamondshovelItem;
import net.mcreator.customoregen.item.SharddiamondpickaxeItem;
import net.mcreator.customoregen.item.SharddiamondaxeItem;
import net.mcreator.customoregen.item.DiamondshardItem;
import net.mcreator.customoregen.item.OreBiomeFinderItem;
import net.mcreator.customoregen.CustomOreGenMod;
public class CustomOreGenModItems {
@@ -42,6 +43,7 @@ public class CustomOreGenModItems {
public static final RegistryObject<Item> DEEPSLATEIRONORE = block(CustomOreGenModBlocks.DEEPSLATEIRONORE);
// Start of user code block custom items
public static final RegistryObject<Item> ORE_BIOME_FINDER = REGISTRY.register("ore_biome_finder", () -> new OreBiomeFinderItem());
// End of user code block custom items
private static RegistryObject<Item> block(RegistryObject<Block> block) {
return REGISTRY.register(block.getId().getPath(), () -> new BlockItem(block.get(), new Item.Properties()));
@@ -0,0 +1,135 @@
package net.mcreator.customoregen.item;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.biome.Biome;
import java.util.*;
public class OreBiomeFinderItem extends Item {
// Tags personnalisés du mod
private static final TagKey<Biome> COLD_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "cold_biomes"));
private static final TagKey<Biome> HOT_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "hot_biomes"));
private static final TagKey<Biome> MOUNTAIN_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "mountain_biomes"));
private static final TagKey<Biome> TEMPERED_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "tempered_biomes"));
private static final TagKey<Biome> RARE_BIOMES_TAG = TagKey.create(Registries.BIOME, new ResourceLocation("custom_ore_gen", "rare_biomes"));
// Minerais par catégorie
private static final List<String> COLD_ORES = Arrays.asList(
"Lapis (stone)",
"Lapis (deepslate)",
"Diamant Concentre"
);
private static final List<String> HOT_ORES = Arrays.asList(
"Or Pur (stone)",
"Or Pur (deepslate)",
"Redstone (stone)",
"Redstone (deepslate)",
"Cuivre (haut)",
"Cuivre (bas)"
);
private static final List<String> MOUNTAIN_ORES = Arrays.asList(
"Emeraude (haute altitude)"
);
private static final List<String> TEMPERED_ORES = Arrays.asList(
"Charbon Concentre",
"Fer (stone)",
"Fer (deepslate)"
);
private static final List<String> RARE_ORES = Arrays.asList(
"Emeraude (basse altitude)"
);
private static final List<String> EVERYWHERE_ORES = Arrays.asList(
"Diamant Shard (deepslate)",
"Bloc Diamant Shard"
);
public OreBiomeFinderItem() {
super(new Item.Properties().stacksTo(1));
}
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
if (!level.isClientSide) {
BlockPos pos = player.blockPosition();
var biomeHolder = level.getBiome(pos);
ResourceKey<Biome> biomeKey = biomeHolder.unwrapKey().orElse(ResourceKey.create(Registries.BIOME, new ResourceLocation("minecraft:plains")));
ResourceLocation biomeId = biomeKey.location();
String biomeName = biomeId.getPath();
player.displayClientMessage(Component.literal("=== Minerais dans: " + biomeName + " ==="), false);
player.displayClientMessage(Component.literal("Biome ID: " + biomeId), false);
// Vérifier les tags personnalisés du mod
Set<String> foundTags = new HashSet<>();
List<String> foundOres = new ArrayList<>();
// Vérifier chaque tag de biome et ajouter les minerais correspondants
if (isBiomeInTag(level, pos, COLD_BIOMES_TAG)) {
foundTags.add("cold_biomes");
foundOres.addAll(COLD_ORES);
}
if (isBiomeInTag(level, pos, HOT_BIOMES_TAG)) {
foundTags.add("hot_biomes");
foundOres.addAll(HOT_ORES);
}
if (isBiomeInTag(level, pos, MOUNTAIN_BIOMES_TAG)) {
foundTags.add("mountain_biomes");
foundOres.addAll(MOUNTAIN_ORES);
}
if (isBiomeInTag(level, pos, TEMPERED_BIOMES_TAG)) {
foundTags.add("tempered_biomes");
foundOres.addAll(TEMPERED_ORES);
}
if (isBiomeInTag(level, pos, RARE_BIOMES_TAG)) {
foundTags.add("rare_biomes");
foundOres.addAll(RARE_ORES);
}
// Ajouter les minerais présents partout
foundOres.addAll(EVERYWHERE_ORES);
// Afficher les tags trouvés
if (!foundTags.isEmpty()) {
player.displayClientMessage(Component.literal("Tags du mod: " + String.join(", ", foundTags)), false);
} else {
player.displayClientMessage(Component.literal("Tags du mod: aucun"), false);
}
// Afficher les minerais (sans doublons)
if (!foundOres.isEmpty()) {
Set<String> uniqueOres = new LinkedHashSet<>(foundOres);
player.displayClientMessage(Component.literal("Minerais trouvables:"), false);
for (String ore : uniqueOres) {
player.displayClientMessage(Component.literal(" * " + ore), false);
}
} else {
player.displayClientMessage(Component.literal("Aucun minerai specifique"), false);
}
}
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide);
}
private static boolean isBiomeInTag(Level level, BlockPos pos, TagKey<Biome> tag) {
return level.getBiome(pos).is(tag);
}
}
+2 -2
View File
@@ -4,8 +4,8 @@ license="Not specified"
[[mods]]
modId="custom_ore_gen"
version="1.0.0"
displayName="custom_ore_gen"
version="2.0.6-forge"
displayName="Custom Ore Gem"
displayURL="https://lanro.eu"
credits="Created using mod maker MCreator - https://mcreator.net/about"
authors="Aulyrius cr\u00E9e via MCreator"
@@ -20,5 +20,6 @@
"block.custom_ore_gen.deepslatepuregoldenore": "Deepslate pure golden ore",
"block.custom_ore_gen.puregoldenore": "Pure golden ore",
"block.custom_ore_gen.highemeraldore": "emerald ore",
"item.custom_ore_gen.sharddiamondshovel": "Shard diamond shovel"
"item.custom_ore_gen.sharddiamondshovel": "Shard diamond shovel",
"item.custom_ore_gen.ore_biome_finder": "Ore Biome Finder"
}
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "custom_ore_gen:item/ore_biome_finder"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"DCD",
"C C",
"DCD"
],
"key": {
"C": {
"item": "minecraft:compass"
},
"D": {
"item": "custom_ore_gen:diamondshard"
}
},
"result": {
"item": "custom_ore_gen:ore_biome_finder",
"count": 1
}
}
@@ -1,20 +1,32 @@
{
"replace": false,
"values": [
"snowy_slopes",
"snowy_beach",
"snowy_plains",
"snowy_taiga",
"ice_spikes",
"old_growth_pine_taiga",
"old_growth_spruce_taiga",
"taiga",
"cold_ocean",
"deep_cold_ocean",
"frozen_peaks",
"jagged_peaks",
"stony_peaks",
"dripstone_caves",
"deep_dark"
"minecraft:taiga",
"minecraft:frozen_ocean",
"minecraft:frozen_river",
"minecraft:snowy_plains",
"minecraft:snowy_beach",
"minecraft:snowy_taiga",
"minecraft:old_growth_pine_taiga",
"minecraft:grove",
"minecraft:snowy_slopes",
"minecraft:jagged_peaks",
"minecraft:frozen_peaks",
"minecraft:cold_ocean",
"minecraft:deep_cold_ocean",
"minecraft:deep_frozen_ocean",
"minecraft:ice_spikes",
"biomesoplenty:auroral_garden",
"biomesoplenty:cold_desert",
"biomesoplenty:maple_woods",
"biomesoplenty:dead_forest",
"biomesoplenty:tundra",
"biomesoplenty:bog",
"biomesoplenty:muskeg",
"biomesoplenty:old_growth_dead_forest",
"biomesoplenty:snowblossom_grove",
"biomesoplenty:snowy_coniferous_forest",
"biomesoplenty:snowy_fir_clearing",
"biomesoplenty:snowy_maple_woods"
]
}
}
@@ -1,17 +1,40 @@
{
"replace": false,
"values": [
"desert",
"badlands",
"eroded_badlands",
"wooded_badlands",
"deep_lukewarm_ocean",
"lukewarm_ocean",
"mangrove_swamp",
"warm_ocean",
"bamboo_jungle",
"jungle",
"sparse_jungle",
"deep_dark"
"minecraft:desert",
"minecraft:jungle",
"minecraft:sparse_jungle",
"minecraft:savanna",
"minecraft:savanna_plateau",
"minecraft:stony_peaks",
"minecraft:warm_ocean",
"minecraft:windswept_savanna",
"minecraft:eroded_badlands",
"minecraft:bamboo_jungle",
"minecraft:mangrove_swamp",
"minecraft:badlands",
"minecraft:wooded_badlands",
"biomesoplenty:bayou",
"biomesoplenty:dryland",
"biomesoplenty:dune_beach",
"biomesoplenty:mystic_grove",
"biomesoplenty:jade_cliffs",
"biomesoplenty:lavender_field",
"biomesoplenty:lavender_forest",
"biomesoplenty:mediterranean_forest",
"biomesoplenty:orchard",
"biomesoplenty:pasture",
"biomesoplenty:prairie",
"biomesoplenty:lush_desert",
"biomesoplenty:lush_savanna",
"biomesoplenty:fungal_jungle",
"biomesoplenty:floodplain",
"biomesoplenty:rainforest",
"biomesoplenty:rocky_rainforest",
"biomesoplenty:tropics",
"biomesoplenty:volcanic_plains",
"biomesoplenty:volcano",
"biomesoplenty:wasteland",
"biomesoplenty:erupting_inferno"
]
}
}
@@ -1,12 +1,16 @@
{
"replace": false,
"values": [
"windswept_hills",
"windswept_gravelly_hills",
"snowy_slopes",
"frozen_peaks",
"jagged_peaks",
"stony_peaks",
"meadow"
"minecraft:jagged_peaks",
"minecraft:frozen_peaks",
"minecraft:stony_peaks",
"minecraft:savanna_plateau",
"minecraft:wooded_badlands",
"minecraft:meadow",
"minecraft:grove",
"minecraft:snowy_slopes",
"biomesoplenty:jade_cliffs",
"biomesoplenty:highland",
"biomesoplenty:crag"
]
}
@@ -1,15 +1,41 @@
{
"replace": false,
"values": [
"mushroom_fields",
"sparse_jungle",
"savanna_plateau",
"sunflower_plains",
"windswept_gravelly_hills",
"cherry_grove",
"flower_forest",
"deep_dark",
"old_growth_birch_forest",
"ice_spikes"
"minecraft:mushroom_fields",
"minecraft:sparse_jungle",
"minecraft:savanna_plateau",
"minecraft:sunflower_plains",
"minecraft:windswept_gravelly_hills",
"minecraft:flower_forest",
"minecraft:ice_spikes",
"minecraft:old_growth_birch_forest",
"minecraft:old_growth_spruce_taiga",
"minecraft:windswept_savanna",
"minecraft:eroded_badlands",
"minecraft:bamboo_jungle",
"minecraft:deep_dark",
"minecraft:dark_forest",
"biomesoplenty:auroral_garden",
"biomesoplenty:mystic_grove",
"biomesoplenty:ominous_woods",
"biomesoplenty:origin_valley",
"biomesoplenty:pumpkin_patch",
"biomesoplenty:rocky_rainforest",
"biomesoplenty:tropics",
"biomesoplenty:floodplain",
"biomesoplenty:fungal_jungle",
"biomesoplenty:jade_cliffs",
"biomesoplenty:lavender_field",
"biomesoplenty:lavender_forest",
"biomesoplenty:mediterranean_forest",
"biomesoplenty:orchard",
"biomesoplenty:rainforest",
"biomesoplenty:redwood_forest",
"biomesoplenty:scrubland",
"biomesoplenty:seasonal_orchard",
"biomesoplenty:crystalline_chasm",
"biomesoplenty:glowing_grotto",
"biomesoplenty:visceral_heap",
"biomesoplenty:withered_abyss"
]
}
}
@@ -1,20 +1,44 @@
{
"replace": false,
"values": [
"birch_forest",
"dark_forest",
"flower_forest",
"forest",
"old_growth_birch_forest",
"windswept_forest",
"swamp",
"mushroom_fields",
"cherry_grove",
"old_growth_pine_taiga",
"windswept_gravelly_hills",
"deep_ocean",
"ocean",
"lush_caves",
"deep_dark"
"minecraft:plains",
"minecraft:meadow",
"minecraft:sunflower_plains",
"minecraft:forest",
"minecraft:birch_forest",
"minecraft:swamp",
"minecraft:taiga",
"minecraft:old_growth_pine_taiga",
"minecraft:river",
"minecraft:beach",
"minecraft:stony_shore",
"minecraft:ocean",
"minecraft:lukewarm_ocean",
"minecraft:deep_ocean",
"minecraft:deep_lukewarm_ocean",
"minecraft:dripstone_caves",
"minecraft:lush_caves",
"biomesoplenty:coniferous_forest",
"biomesoplenty:fir_clearing",
"biomesoplenty:field",
"biomesoplenty:forested_field",
"biomesoplenty:seasonal_forest",
"biomesoplenty:seasonal_orchard",
"biomesoplenty:pumpkin_patch",
"biomesoplenty:grassland",
"biomesoplenty:highland",
"biomesoplenty:spider_nest",
"biomesoplenty:moor",
"biomesoplenty:origin_valley",
"biomesoplenty:shrubland",
"biomesoplenty:wetland",
"biomesoplenty:clover_patch",
"biomesoplenty:redwood_forest",
"biomesoplenty:rocky_shrubland",
"biomesoplenty:scrubland",
"biomesoplenty:woodland",
"biomesoplenty:old_growth_woodland",
"biomesoplenty:marsh",
"biomesoplenty:undergrowth"
]
}
}