Compare commits
5
Commits
baa1972289
...
e3e4296c33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3e4296c33 | ||
|
|
0846c6332b | ||
|
|
cff588c98b | ||
|
|
3d2ea01d97 | ||
|
|
0c093d1b0c |
@@ -1,6 +1,6 @@
|
||||
# Custom Ore Gem - Developer Guide for Agents
|
||||
|
||||
This repository is a Minecraft **NeoForge 1.21.1** mod created with **MCreator**. Agents must follow these strict guidelines to ensure build stability and code preservation.
|
||||
This repository is a Minecraft **NeoForge 1.21.1** mod. It was originally scaffolded with MCreator but is now **fully hand-maintained** — all files are safe to edit. Agents must follow these guidelines to ensure build stability.
|
||||
|
||||
## 1. Build & Test Commands
|
||||
|
||||
@@ -36,12 +36,12 @@ Use the Gradle wrapper for all operations. Ensure you are using Java 21 (NeoForg
|
||||
|
||||
- **Run Single Test Class:**
|
||||
```bash
|
||||
./gradlew test --tests "net.mcreator.customoregen.OresCommandTest"
|
||||
./gradlew test --tests "com.aulyrius.customoregen.OresCommandTest"
|
||||
```
|
||||
|
||||
- **Run Single Test Method:**
|
||||
```bash
|
||||
./gradlew test --tests "net.mcreator.customoregen.OresCommandTest.testCommandRegistration_ShouldRegisterOresCommand"
|
||||
./gradlew test --tests "com.aulyrius.customoregen.OresCommandTest.testCommandRegistration_ShouldRegisterOresCommand"
|
||||
```
|
||||
|
||||
- **Clean Project:**
|
||||
@@ -49,27 +49,14 @@ Use the Gradle wrapper for all operations. Ensure you are using Java 21 (NeoForg
|
||||
./gradlew clean
|
||||
```
|
||||
|
||||
## 2. MCreator & Code Preservation
|
||||
## 2. Code Ownership
|
||||
|
||||
**CRITICAL:** This project is partially generated by MCreator.
|
||||
- **Generated Files:** Many files in `src/main/java` are regenerated on every build or MCreator export.
|
||||
- **User Code Blocks:** You **MUST** only edit code within designated user code blocks in these files.
|
||||
```java
|
||||
// Start of user code block [block_name]
|
||||
// ... YOUR CODE HERE ...
|
||||
// End of user code block [block_name]
|
||||
```
|
||||
- If a file does not have these blocks, assume it is **UNSAFE** to edit unless you created it yourself.
|
||||
|
||||
- **Safe Files:**
|
||||
- Files strictly created by you (e.g., in `src/test/java`).
|
||||
- New utility classes or event handlers not managed by MCreator.
|
||||
|
||||
- **Do NOT** directly modify the following unless inside a user block:
|
||||
- `CustomOreGenModBlocks.java`
|
||||
- `CustomOreGenModItems.java`
|
||||
- `CustomOreGenModTabs.java`
|
||||
- Any file in `net.mcreator.customoregen.procedures` (unless explicitly safe).
|
||||
The project was originally generated by MCreator but is no longer maintained with it
|
||||
(MCreator is not installed anymore; the build is plain Gradle + NeoForge ModDev).
|
||||
- **Every file** in `src/main/java` and `src/test/java` is hand-maintained and safe to edit.
|
||||
- The historical "user code block" markers were removed; there is no regeneration step.
|
||||
- Keep MCreator-era naming quirks (e.g. `SharddiamondpickaxeItem`) unless a rename is
|
||||
explicitly requested, to keep diffs readable.
|
||||
|
||||
## 3. Code Style & Conventions
|
||||
|
||||
@@ -85,14 +72,14 @@ Use the Gradle wrapper for all operations. Ensure you are using Java 21 (NeoForg
|
||||
- **Methods:** camelCase (e.g., `queueServerWork`).
|
||||
- **Constants:** UPPER_SNAKE_CASE (e.g., `MODID`, `COLD_BIOMES_TAG`).
|
||||
- **Fields:** camelCase (e.g., `workQueue`, `oreGenConfig`).
|
||||
- **Packages:** `net.mcreator.customoregen` (lowercase).
|
||||
- **Packages:** `com.aulyrius.customoregen` (lowercase).
|
||||
|
||||
### Imports
|
||||
- Group imports in this specific order:
|
||||
1. Java/Standard Libraries (`java.*`, `javax.*`)
|
||||
2. Third-party Libraries (e.g., `org.apache.logging.log4j.*`)
|
||||
3. Minecraft/NeoForge (`net.minecraft.*`, `net.neoforged.*`)
|
||||
4. Project Classes (`net.mcreator.customoregen.*`)
|
||||
4. Project Classes (`com.aulyrius.customoregen.*`)
|
||||
- Avoid `import *` unless there are many imports from the same package (e.g., `java.util.*` is acceptable if heavily used, but explicit imports are preferred for clarity).
|
||||
|
||||
### Logging
|
||||
@@ -109,10 +96,10 @@ Use the Gradle wrapper for all operations. Ensure you are using Java 21 (NeoForg
|
||||
- **Event Bus:**
|
||||
- The `@Mod` class registers the `IEventBus`.
|
||||
- Use `@SubscribeEvent` for event handling.
|
||||
- Event handlers often reside in `net.mcreator.customoregen.event` or static inner classes annotated with `@EventBusSubscriber`.
|
||||
- Event handlers often reside in `com.aulyrius.customoregen.event` or static inner classes annotated with `@EventBusSubscriber`.
|
||||
|
||||
- **Configuration:**
|
||||
- Located in `net.mcreator.customoregen.config.ModConfigs`.
|
||||
- Located in `com.aulyrius.customoregen.config.ModConfigs`.
|
||||
- Uses `ModConfig.Type.COMMON` built with `ModConfigSpec`.
|
||||
- Access configs via the public static fields (e.g., `ModConfigs.ORE_GEN.shardDiamondOreCount.get()`).
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ mod_id=custom_ore_gen
|
||||
mod_name=Custom Ore Gen
|
||||
mod_group_id=com.aulyrius.custom_ore_gen
|
||||
mod_license=MIT
|
||||
mod_authors=Aulyrius crée via MCreator
|
||||
mod_authors=Aulyrius
|
||||
mod_description=Changement de la distribution des ressources sur Minecraft, pour NeoForge 1.21.1
|
||||
|
||||
# Minecraft and NeoForge Versions
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.aulyrius.customoregen;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModTabs;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModItems;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.item.ShardDiamondArmorMaterial;
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
import net.neoforged.fml.config.ModConfig;
|
||||
|
||||
|
||||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import com.aulyrius.customoregen.loot.CustomOreLootModifier;
|
||||
import com.aulyrius.customoregen.worldgen.WorldGenRegistration;
|
||||
|
||||
|
||||
@Mod(CustomOreGenMod.MODID)
|
||||
public class CustomOreGenMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(CustomOreGenMod.class);
|
||||
public static final String MODID = "custom_ore_gen";
|
||||
public static final DeferredRegister<MapCodec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, MODID);
|
||||
|
||||
public CustomOreGenMod(IEventBus modEventBus, ModContainer container) {
|
||||
container.registerConfig(ModConfig.Type.COMMON, ModConfigs.SPEC);
|
||||
LOOT_MODIFIERS.register("custom_ore_drops", () -> CustomOreLootModifier.CODEC);
|
||||
|
||||
CustomOreGenModBlocks.REGISTRY.register(modEventBus);
|
||||
CustomOreGenModItems.REGISTRY.register(modEventBus);
|
||||
ShardDiamondArmorMaterial.REGISTRY.register(modEventBus);
|
||||
|
||||
CustomOreGenModTabs.REGISTRY.register(modEventBus);
|
||||
LOOT_MODIFIERS.register(modEventBus);
|
||||
|
||||
WorldGenRegistration.BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
WorldGenRegistration.DENSITY_FUNCTION_TYPES.register(modEventBus);
|
||||
WorldGenRegistration.PLACEMENT_MODIFIERS.register(modEventBus);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.aulyrius.customoregen;
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
|
||||
/**
|
||||
* Central mapping between the mod's ore blocks and their logical ore type.
|
||||
*
|
||||
* <p>The ore type drives both item drops ({@code CustomOreLootModifier}) and experience
|
||||
* ({@code ConfigurableOreDropsProcedure} via {@code OreDropMath}). Single source of truth:
|
||||
* previously this mapping was copy-pasted in two classes.</p>
|
||||
*/
|
||||
public final class OreTypes {
|
||||
|
||||
public static final String SHARD_DIAMOND = "shard_diamond";
|
||||
public static final String CONCENTRATED_DIAMOND = "concentrated_diamond";
|
||||
public static final String CONCENTRATED_COAL = "concentrated_coal";
|
||||
public static final String PURE_GOLDEN = "pure_golden";
|
||||
public static final String IMPURE_IRON = "impure_iron";
|
||||
public static final String LAPIS = "lapis";
|
||||
public static final String REDSTONE = "redstone";
|
||||
public static final String EMERALD = "emerald";
|
||||
public static final String COPPER = "copper";
|
||||
|
||||
private OreTypes() {}
|
||||
|
||||
/**
|
||||
* Returns the logical ore type for a block, or {@code null} if the block is not one of
|
||||
* the mod's custom ores.
|
||||
*/
|
||||
public static String of(Block block) {
|
||||
if (block == CustomOreGenModBlocks.SHARDDIAMONDBLOCKORE.get() || block == CustomOreGenModBlocks.DEEPSLATESHARDDIAMONDORE.get()) return SHARD_DIAMOND;
|
||||
if (block == CustomOreGenModBlocks.CONCENTRATEDCOALORE.get()) return CONCENTRATED_COAL;
|
||||
if (block == CustomOreGenModBlocks.PUREGOLDENORE.get() || block == CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get()) return PURE_GOLDEN;
|
||||
if (block == CustomOreGenModBlocks.IRONORE.get() || block == CustomOreGenModBlocks.DEEPSLATEIRONORE.get()) return IMPURE_IRON;
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get()) return CONCENTRATED_DIAMOND;
|
||||
if (block == CustomOreGenModBlocks.LAPISORE.get() || block == CustomOreGenModBlocks.DEEPSLATELAPISORE.get()) return LAPIS;
|
||||
if (block == CustomOreGenModBlocks.REDSTONEORE.get() || block == CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get()) return REDSTONE;
|
||||
if (block == CustomOreGenModBlocks.HIGHEMERALDORE.get() || block == CustomOreGenModBlocks.LOWEREMERALDORE.get()) return EMERALD;
|
||||
if (block == CustomOreGenModBlocks.COPPERHIGHORE.get() || block == CustomOreGenModBlocks.COPPERLOWERORE.get()) return COPPER;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.aulyrius.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.network.chat.Component;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
||||
import com.aulyrius.customoregen.worldgen.OreZoneCatalog;
|
||||
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class OresCommand {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterCommands(RegisterCommandsEvent event) {
|
||||
event.getDispatcher().register(Commands.literal("ores")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(OresCommand::executeOres));
|
||||
event.getDispatcher().register(Commands.literal("ore")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(OresCommand::executeOres));
|
||||
}
|
||||
|
||||
private static int executeOres(CommandContext<CommandSourceStack> context) {
|
||||
if (!(context.getSource().getEntity() instanceof net.minecraft.world.entity.player.Player player)) {
|
||||
context.getSource().sendFailure(Component.literal("Cette commande ne peut etre utilisee que par un joueur"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x = player.blockPosition().getX();
|
||||
int z = player.blockPosition().getZ();
|
||||
|
||||
for (Component line : OreZoneCatalog.buildZoneReport(x, z)) {
|
||||
context.getSource().sendSuccess(() -> line, true);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class DeepslatediamondoreBlock extends Block {
|
||||
public DeepslatediamondoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 11f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class DeepslateironoreBlock extends Block {
|
||||
public DeepslateironoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class DeepslatelapisoreBlock extends Block {
|
||||
public DeepslatelapisoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(4.5f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class DeepslatepuregoldenoreBlock extends Block {
|
||||
public DeepslatepuregoldenoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class DeepslateredstoneoreBlock extends Block {
|
||||
public DeepslateredstoneoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).lightLevel(s -> 1).requiresCorrectToolForDrops().hasPostProcess((bs, br, bp) -> true).emissiveRendering((bs, br, bp) -> true));
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class HighemeraldoreBlock extends Block {
|
||||
public HighemeraldoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class IronoreBlock extends Block {
|
||||
public IronoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(2f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class LapisoreBlock extends Block {
|
||||
public LapisoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class LoweremeraldoreBlock extends Block {
|
||||
public LoweremeraldoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(4.5f, 10f).requiresCorrectToolForDrops());
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class PuregoldenoreBlock extends Block {
|
||||
public PuregoldenoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f));
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
public class RedstoneoreBlock extends Block {
|
||||
public RedstoneoreBlock() {
|
||||
super(BlockBehaviour.Properties.of().sound(SoundType.STONE).strength(3f, 10f).lightLevel(s -> 1).requiresCorrectToolForDrops());
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.block;
|
||||
package com.aulyrius.customoregen.block;
|
||||
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.aulyrius.customoregen.config;
|
||||
|
||||
public class ConfigHelper {
|
||||
// Helper method to safely access config values
|
||||
public static boolean isFeatureEnabled(String featureName) {
|
||||
switch (featureName) {
|
||||
case "shardDiamondOre":
|
||||
return ModConfigs.FEATURES.enableShardDiamondOre.get();
|
||||
case "concentratedOres":
|
||||
return ModConfigs.FEATURES.enableConcentratedOres.get();
|
||||
case "impureOres":
|
||||
return ModConfigs.FEATURES.enableImpureOres.get();
|
||||
case "pureGoldenOre":
|
||||
return ModConfigs.FEATURES.enablePureGoldenOre.get();
|
||||
case "customEmeraldOres":
|
||||
return ModConfigs.FEATURES.enableCustomEmeraldOres.get();
|
||||
case "customCopperOres":
|
||||
return ModConfigs.FEATURES.enableCustomCopperOres.get();
|
||||
case "vanillaOreVariants":
|
||||
return ModConfigs.FEATURES.enableVanillaOreVariants.get();
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-28
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
package com.aulyrius.customoregen.config;
|
||||
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
|
||||
@@ -104,9 +104,6 @@ public class ModConfigs {
|
||||
shardDiamondArmorToughness = builder
|
||||
.comment("Toughness of Shard Diamond Armor (default: 1.0)")
|
||||
.defineInRange("armorToughness", 1.0, 0.0, 10.0);
|
||||
shardDiamondArmorKnockbackResistance = builder
|
||||
.comment("Knockback resistance of Shard Diamond Armor (default: 0.0)")
|
||||
.defineInRange("armorKnockbackResistance", 0.0, 0.0, 1.0);
|
||||
builder.pop();
|
||||
|
||||
builder.pop();
|
||||
@@ -117,7 +114,6 @@ public class ModConfigs {
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondLeggingsDurability;
|
||||
public final ModConfigSpec.ConfigValue<Integer> shardDiamondBootsDurability;
|
||||
public final ModConfigSpec.DoubleValue shardDiamondArmorToughness;
|
||||
public final ModConfigSpec.DoubleValue shardDiamondArmorKnockbackResistance;
|
||||
}
|
||||
|
||||
// Configuration pour les drops des minerais
|
||||
@@ -142,9 +138,6 @@ public class ModConfigs {
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
|
||||
public final ModConfigSpec.BooleanValue impureIronOreEnableFortune;
|
||||
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMaxDrops;
|
||||
|
||||
public final ModConfigSpec.ConfigValue<Integer> lapisOreMinDrops;
|
||||
public final ModConfigSpec.ConfigValue<Integer> lapisOreMaxDrops;
|
||||
public final ModConfigSpec.BooleanValue lapisOreEnableFortune;
|
||||
@@ -160,9 +153,6 @@ public class ModConfigs {
|
||||
public final ModConfigSpec.ConfigValue<Integer> copperOreMaxDrops;
|
||||
public final ModConfigSpec.BooleanValue copperOreEnableFortune;
|
||||
|
||||
public final ModConfigSpec.ConfigValue<Integer> oreExperienceDrops;
|
||||
|
||||
|
||||
public DropsConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("drops");
|
||||
|
||||
@@ -224,12 +214,6 @@ public class ModConfigs {
|
||||
impureIronOreEnableFortune = builder
|
||||
.comment("Enable Fortune enchantment on Iron Ore (default: false) - vanilla iron/gold ores ignore Fortune")
|
||||
.define("enableFortune", false);
|
||||
impureGoldOreMinDrops = builder
|
||||
.comment("Minimum raw gold dropped by Impure Gold Ore (default: 1)")
|
||||
.defineInRange("goldMinDrops", 1, 0, 64);
|
||||
impureGoldOreMaxDrops = builder
|
||||
.comment("Maximum raw gold dropped by Impure Gold Ore (default: 1)")
|
||||
.defineInRange("goldMaxDrops", 1, 0, 64);
|
||||
builder.pop();
|
||||
|
||||
builder.push("vanilla_ore_variants");
|
||||
@@ -267,19 +251,11 @@ public class ModConfigs {
|
||||
.comment("Enable Fortune enchantment on Copper Ore (default: true) - vanilla equivalent")
|
||||
.define("enableFortune", true);
|
||||
builder.pop();
|
||||
|
||||
oreExperienceDrops = builder
|
||||
|
||||
.comment("Experience dropped when mining custom ores (default: 2)")
|
||||
.defineInRange("oreExperience", 2, 0, 100);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
|
||||
// Configuration pour activer/désactiver les fonctionnalités
|
||||
public static class FeatureToggleConfig {
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondTools;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
|
||||
public final ModConfigSpec.ConfigValue<Boolean> enableImpureOres;
|
||||
@@ -291,9 +267,6 @@ public class ModConfigs {
|
||||
public FeatureToggleConfig(ModConfigSpec.Builder builder) {
|
||||
builder.push("features");
|
||||
|
||||
enableShardDiamondTools = builder
|
||||
.comment("Enable Shard Diamond Tools (default: true)")
|
||||
.define("enableShardDiamondTools", true);
|
||||
enableShardDiamondOre = builder
|
||||
.comment("Enable Shard Diamond Ore generation (default: true)")
|
||||
.define("enableShardDiamondOre", true);
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.aulyrius.customoregen.event;
|
||||
|
||||
import net.neoforged.neoforge.event.level.BlockDropsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
||||
import com.aulyrius.customoregen.OreTypes;
|
||||
import com.aulyrius.customoregen.procedures.ConfigurableOreDropsProcedure;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class OreBreakEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockDrops(BlockDropsEvent event) {
|
||||
String oreType = OreTypes.of(event.getState().getBlock());
|
||||
|
||||
// Item drops are handled by CustomOreLootModifier (Global Loot Modifier)
|
||||
// to ensure compatibility with machines and avoid duplication.
|
||||
// This handler only spawns the experience orb for player-mined ores.
|
||||
if (oreType != null && event.getBreaker() != null) {
|
||||
ConfigurableOreDropsProcedure.execute(event.getLevel(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), event.getBreaker(), oreType);
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-24
@@ -1,8 +1,4 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
package com.aulyrius.customoregen.init;
|
||||
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
@@ -10,23 +6,23 @@ import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.block.SharddiamondblockoreBlock;
|
||||
import net.mcreator.customoregen.block.RedstoneoreBlock;
|
||||
import net.mcreator.customoregen.block.PuregoldenoreBlock;
|
||||
import net.mcreator.customoregen.block.LoweremeraldoreBlock;
|
||||
import net.mcreator.customoregen.block.LapisoreBlock;
|
||||
import net.mcreator.customoregen.block.IronoreBlock;
|
||||
import net.mcreator.customoregen.block.HighemeraldoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslatesharddiamondoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslateredstoneoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslatepuregoldenoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslatelapisoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslateironoreBlock;
|
||||
import net.mcreator.customoregen.block.CopperloweroreBlock;
|
||||
import net.mcreator.customoregen.block.CopperhighoreBlock;
|
||||
import net.mcreator.customoregen.block.DeepslatediamondoreBlock;
|
||||
import net.mcreator.customoregen.block.ConcentratedcoaloreBlock;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import com.aulyrius.customoregen.block.SharddiamondblockoreBlock;
|
||||
import com.aulyrius.customoregen.block.RedstoneoreBlock;
|
||||
import com.aulyrius.customoregen.block.PuregoldenoreBlock;
|
||||
import com.aulyrius.customoregen.block.LoweremeraldoreBlock;
|
||||
import com.aulyrius.customoregen.block.LapisoreBlock;
|
||||
import com.aulyrius.customoregen.block.IronoreBlock;
|
||||
import com.aulyrius.customoregen.block.HighemeraldoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslatesharddiamondoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslateredstoneoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslatepuregoldenoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslatelapisoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslateironoreBlock;
|
||||
import com.aulyrius.customoregen.block.CopperloweroreBlock;
|
||||
import com.aulyrius.customoregen.block.CopperhighoreBlock;
|
||||
import com.aulyrius.customoregen.block.DeepslatediamondoreBlock;
|
||||
import com.aulyrius.customoregen.block.ConcentratedcoaloreBlock;
|
||||
import com.aulyrius.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -48,6 +44,4 @@ public class CustomOreGenModBlocks {
|
||||
public static final Supplier<Block> LOWEREMERALDORE = REGISTRY.register("loweremeraldore", () -> new LoweremeraldoreBlock());
|
||||
public static final Supplier<Block> IRONORE = REGISTRY.register("ironore", () -> new IronoreBlock());
|
||||
public static final Supplier<Block> DEEPSLATEIRONORE = REGISTRY.register("deepslateironore", () -> new DeepslateironoreBlock());
|
||||
// Start of user code block custom blocks
|
||||
// End of user code block custom blocks
|
||||
}
|
||||
+12
-18
@@ -1,8 +1,4 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
package com.aulyrius.customoregen.init;
|
||||
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
@@ -12,17 +8,17 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
|
||||
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.item.SharddiamondhelmetItem;
|
||||
import net.mcreator.customoregen.item.SharddiamondchestplateItem;
|
||||
import net.mcreator.customoregen.item.SharddiamondleggingsItem;
|
||||
import net.mcreator.customoregen.item.SharddiamondbootsItem;
|
||||
import net.mcreator.customoregen.item.SharddiamondpaxelItem;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import com.aulyrius.customoregen.item.SharddiamondshovelItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondpickaxeItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondaxeItem;
|
||||
import com.aulyrius.customoregen.item.DiamondshardItem;
|
||||
import com.aulyrius.customoregen.item.OreBiomeFinderItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondhelmetItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondchestplateItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondleggingsItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondbootsItem;
|
||||
import com.aulyrius.customoregen.item.SharddiamondpaxelItem;
|
||||
import com.aulyrius.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -64,7 +60,6 @@ public class CustomOreGenModItems {
|
||||
public static final Supplier<Item> DEEPSLATEIRONORE = REGISTRY.register("deepslateironore",
|
||||
() -> new BlockItem(CustomOreGenModBlocks.DEEPSLATEIRONORE.get(), new Item.Properties()));
|
||||
|
||||
// Start of user code block custom items
|
||||
public static final Supplier<Item> ORE_BIOME_FINDER = REGISTRY.register("ore_biome_finder", () -> new OreBiomeFinderItem());
|
||||
|
||||
// Diamond Shard Armor
|
||||
@@ -75,7 +70,6 @@ public class CustomOreGenModItems {
|
||||
|
||||
// Diamond Shard Paxel
|
||||
public static final Supplier<Item> SHARDDIAMONDPAXEL = REGISTRY.register("sharddiamondpaxel", () -> new SharddiamondpaxelItem());
|
||||
// End of user code block custom items
|
||||
|
||||
// Tool items
|
||||
public static final Supplier<Item> SHARDDIAMONDPICKAXE = REGISTRY.register("sharddiamondpickaxe", () -> new SharddiamondpickaxeItem());
|
||||
+3
-9
@@ -1,8 +1,4 @@
|
||||
|
||||
/*
|
||||
* MCreator note: This file will be REGENERATED on each build.
|
||||
*/
|
||||
package net.mcreator.customoregen.init;
|
||||
package com.aulyrius.customoregen.init;
|
||||
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
@@ -16,15 +12,14 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import com.aulyrius.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.MOD)
|
||||
public class CustomOreGenModTabs {
|
||||
public static final DeferredRegister<CreativeModeTab> REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, CustomOreGenMod.MODID);
|
||||
|
||||
// Start of user code block tabs
|
||||
public static final Supplier<CreativeModeTab> CUSTOM_ORE_GEN_TAB = REGISTRY.register("custom_ore_gen_tab",
|
||||
() -> CreativeModeTab.builder()
|
||||
.title(Component.translatable("itemGroup.custom_ore_gen"))
|
||||
@@ -64,7 +59,6 @@ public class CustomOreGenModTabs {
|
||||
output.accept(CustomOreGenModItems.SHARDDIAMONDBOOTS.get());
|
||||
})
|
||||
.build());
|
||||
// End of user code block tabs
|
||||
|
||||
@SubscribeEvent
|
||||
public static void buildTabContentsVanilla(BuildCreativeModeTabContentsEvent tabData) {
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
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 com.aulyrius.customoregen.worldgen.OreZoneCatalog;
|
||||
|
||||
public class OreBiomeFinderItem extends Item {
|
||||
|
||||
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) {
|
||||
int x = player.blockPosition().getX();
|
||||
int z = player.blockPosition().getZ();
|
||||
|
||||
for (Component line : OreZoneCatalog.buildZoneReport(x, z)) {
|
||||
player.displayClientMessage(line, false);
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
/**
|
||||
* Base class for Shard Diamond armor items with custom stats matching Forge
|
||||
@@ -14,7 +14,7 @@ import net.mcreator.customoregen.config.ModConfigs;
|
||||
public abstract class ShardDiamondArmorItem extends ArmorItem {
|
||||
|
||||
public ShardDiamondArmorItem(ArmorItem.Type type, Item.Properties properties) {
|
||||
super(ShardDiamondArmorMaterial.SHARD_DIAMOND, type, properties.stacksTo(64));
|
||||
super(ShardDiamondArmorMaterial.SHARD_DIAMOND, type, properties.stacksTo(1));
|
||||
}
|
||||
|
||||
/**
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -9,8 +9,8 @@ import net.minecraft.world.item.ArmorItem;
|
||||
import net.minecraft.world.item.ArmorMaterial;
|
||||
import net.minecraft.world.item.ArmorMaterials;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import com.aulyrius.customoregen.CustomOreGenMod;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
/**
|
||||
* Custom armor material wrapper for Diamond Shard armor.
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
/**
|
||||
* Shared {@link Tier} for all Shard Diamond tools (previously an anonymous Tier
|
||||
* copy-pasted in each tool class). Stats are read live from the config, with
|
||||
* fallbacks for the pre-config-load phase (item registration).
|
||||
*/
|
||||
public enum ShardDiamondToolTier implements Tier {
|
||||
PICKAXE(200, 7.0f, 1.0f, 9,
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPickaxeAttackDamage.get()),
|
||||
AXE(200, 7.0f, 6.0f, 9,
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondAxeAttackDamage.get()),
|
||||
SHOVEL(200, 4.0f, 2.0f, 9,
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondShovelAttackDamage.get()),
|
||||
PAXEL(1000, 6.5f, 4.0f, 14,
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPaxelDurability.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPaxelSpeed.get(),
|
||||
() -> ModConfigs.TOOL_STATS.shardDiamondPaxelAttackDamage.get());
|
||||
|
||||
private final int fallbackUses;
|
||||
private final float fallbackSpeed;
|
||||
private final float fallbackAttackDamage;
|
||||
private final int enchantmentValue;
|
||||
private final IntSupplier uses;
|
||||
private final DoubleSupplier speed;
|
||||
private final IntSupplier attackDamage;
|
||||
|
||||
ShardDiamondToolTier(int fallbackUses, float fallbackSpeed, float fallbackAttackDamage, int enchantmentValue,
|
||||
IntSupplier uses, DoubleSupplier speed, IntSupplier attackDamage) {
|
||||
this.fallbackUses = fallbackUses;
|
||||
this.fallbackSpeed = fallbackSpeed;
|
||||
this.fallbackAttackDamage = fallbackAttackDamage;
|
||||
this.enchantmentValue = enchantmentValue;
|
||||
this.uses = uses;
|
||||
this.speed = speed;
|
||||
this.attackDamage = attackDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUses() {
|
||||
return ModConfigs.isLoaded() ? uses.getAsInt() : fallbackUses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return ModConfigs.isLoaded() ? (float) speed.getAsDouble() : fallbackSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamageBonus() {
|
||||
return ModConfigs.isLoaded() ? attackDamage.getAsInt() : fallbackAttackDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantmentValue() {
|
||||
return enchantmentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondaxeItem extends AxeItem {
|
||||
public SharddiamondaxeItem() {
|
||||
super(ShardDiamondToolTier.AXE, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_AXE)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
+3
-33
@@ -1,46 +1,16 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondpaxelItem extends PickaxeItem {
|
||||
public SharddiamondpaxelItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelDurability.get() : 1000;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelSpeed.get().floatValue() : 6.5f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPaxelAttackDamage.get().floatValue() : 4.0f;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 14;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
super(ShardDiamondToolTier.PAXEL, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondpickaxeItem extends PickaxeItem {
|
||||
public SharddiamondpickaxeItem() {
|
||||
super(ShardDiamondToolTier.PICKAXE, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_PICKAXE)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.aulyrius.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondshovelItem extends ShovelItem {
|
||||
public SharddiamondshovelItem() {
|
||||
super(ShardDiamondToolTier.SHOVEL, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_SHOVEL)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get().floatValue() : 4.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package com.aulyrius.customoregen.loot;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||
import net.neoforged.neoforge.common.loot.LootModifier;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
import com.aulyrius.customoregen.OreTypes;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModBlocks;
|
||||
import com.aulyrius.customoregen.init.CustomOreGenModItems;
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
import com.aulyrius.customoregen.procedures.OreDropMath;
|
||||
import com.aulyrius.customoregen.CustomOreGenMod;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CustomOreLootModifier extends LootModifier {
|
||||
public static final MapCodec<CustomOreLootModifier> CODEC = RecordCodecBuilder.mapCodec(inst ->
|
||||
codecStart(inst).apply(inst, CustomOreLootModifier::new)
|
||||
);
|
||||
|
||||
/** Drop parameters for one ore type, read live from the config. */
|
||||
private record DropSpec(Supplier<Integer> minDrops, Supplier<Integer> maxDrops,
|
||||
Supplier<Boolean> enableFortune, Supplier<Item> item) {}
|
||||
|
||||
private static final Map<String, DropSpec> DROP_SPECS = Map.of(
|
||||
OreTypes.SHARD_DIAMOND, new DropSpec(ModConfigs.DROPS.shardDiamondOreMinDrops::get,
|
||||
ModConfigs.DROPS.shardDiamondOreMaxDrops::get, ModConfigs.DROPS.shardDiamondOreEnableFortune::get,
|
||||
CustomOreGenModItems.DIAMONDSHARD::get),
|
||||
OreTypes.CONCENTRATED_DIAMOND, new DropSpec(ModConfigs.DROPS.concentratedDiamondOreMinDrops::get,
|
||||
ModConfigs.DROPS.concentratedDiamondOreMaxDrops::get, ModConfigs.DROPS.concentratedDiamondOreEnableFortune::get,
|
||||
() -> Items.DIAMOND),
|
||||
OreTypes.CONCENTRATED_COAL, new DropSpec(ModConfigs.DROPS.concentratedCoalOreMinDrops::get,
|
||||
ModConfigs.DROPS.concentratedCoalOreMaxDrops::get, ModConfigs.DROPS.concentratedCoalOreEnableFortune::get,
|
||||
() -> Items.COAL),
|
||||
OreTypes.PURE_GOLDEN, new DropSpec(ModConfigs.DROPS.pureGoldenOreMinDrops::get,
|
||||
ModConfigs.DROPS.pureGoldenOreMaxDrops::get, ModConfigs.DROPS.pureGoldenOreEnableFortune::get,
|
||||
() -> Items.RAW_GOLD),
|
||||
OreTypes.IMPURE_IRON, new DropSpec(ModConfigs.DROPS.impureIronOreMinDrops::get,
|
||||
ModConfigs.DROPS.impureIronOreMaxDrops::get, ModConfigs.DROPS.impureIronOreEnableFortune::get,
|
||||
() -> Items.RAW_IRON),
|
||||
OreTypes.LAPIS, new DropSpec(ModConfigs.DROPS.lapisOreMinDrops::get,
|
||||
ModConfigs.DROPS.lapisOreMaxDrops::get, ModConfigs.DROPS.lapisOreEnableFortune::get,
|
||||
() -> Items.LAPIS_LAZULI),
|
||||
OreTypes.REDSTONE, new DropSpec(ModConfigs.DROPS.redstoneOreMinDrops::get,
|
||||
ModConfigs.DROPS.redstoneOreMaxDrops::get, ModConfigs.DROPS.redstoneOreEnableFortune::get,
|
||||
() -> Items.REDSTONE),
|
||||
OreTypes.EMERALD, new DropSpec(ModConfigs.DROPS.emeraldOreMinDrops::get,
|
||||
ModConfigs.DROPS.emeraldOreMaxDrops::get, () -> true,
|
||||
() -> Items.EMERALD),
|
||||
OreTypes.COPPER, new DropSpec(ModConfigs.DROPS.copperOreMinDrops::get,
|
||||
ModConfigs.DROPS.copperOreMaxDrops::get, ModConfigs.DROPS.copperOreEnableFortune::get,
|
||||
() -> Items.RAW_COPPER)
|
||||
);
|
||||
|
||||
public CustomOreLootModifier(LootItemCondition[] conditionsIn) {
|
||||
super(conditionsIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends IGlobalLootModifier> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
try {
|
||||
BlockState state = context.getParamOrNull(LootContextParams.BLOCK_STATE);
|
||||
if (state == null) return generatedLoot;
|
||||
|
||||
Block block = state.getBlock();
|
||||
String oreType = OreTypes.of(block);
|
||||
|
||||
if (oreType != null) {
|
||||
ItemStack tool = context.getParamOrNull(LootContextParams.TOOL);
|
||||
var enchantmentRegistry = context.getLevel().registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
|
||||
// Silk Touch: drop the ore block itself instead of the custom drops
|
||||
if (tool != null && !tool.isEmpty()
|
||||
&& tool.getEnchantmentLevel(enchantmentRegistry.getOrThrow(Enchantments.SILK_TOUCH)) > 0) {
|
||||
// For Diamond Shard, we want to keep the modded block itself
|
||||
if (oreType.equals(OreTypes.SHARD_DIAMOND)) {
|
||||
ObjectArrayList<ItemStack> shardLoot = new ObjectArrayList<>();
|
||||
shardLoot.add(new ItemStack(block));
|
||||
return shardLoot;
|
||||
}
|
||||
// For others, convert to vanilla block equivalent
|
||||
ItemStack vanillaBlock = getVanillaBlockDrop(block);
|
||||
if (!vanillaBlock.isEmpty()) {
|
||||
ObjectArrayList<ItemStack> silkLoot = new ObjectArrayList<>();
|
||||
silkLoot.add(vanillaBlock);
|
||||
return silkLoot;
|
||||
}
|
||||
return generatedLoot;
|
||||
}
|
||||
|
||||
// No Silk Touch: replace with custom drops (fortune-aware)
|
||||
int fortuneLevel = 0;
|
||||
if (tool != null && !tool.isEmpty()) {
|
||||
fortuneLevel = tool.getEnchantmentLevel(enchantmentRegistry.getOrThrow(Enchantments.FORTUNE));
|
||||
}
|
||||
|
||||
ObjectArrayList<ItemStack> customDrops = new ObjectArrayList<>();
|
||||
addCustomDrops(customDrops, oreType, fortuneLevel, context.getRandom());
|
||||
|
||||
// Only return custom drops if we generated some, otherwise fallback to original
|
||||
if (!customDrops.isEmpty()) {
|
||||
return customDrops;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CustomOreGenMod.LOGGER.error("Error applying CustomOreLootModifier", e);
|
||||
}
|
||||
|
||||
return generatedLoot;
|
||||
}
|
||||
|
||||
private ItemStack getVanillaBlockDrop(Block block) {
|
||||
if (block == CustomOreGenModBlocks.CONCENTRATEDCOALORE.get()) return new ItemStack(Blocks.COAL_ORE);
|
||||
if (block == CustomOreGenModBlocks.IRONORE.get()) return new ItemStack(Blocks.IRON_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEIRONORE.get()) return new ItemStack(Blocks.DEEPSLATE_IRON_ORE);
|
||||
if (block == CustomOreGenModBlocks.PUREGOLDENORE.get()) return new ItemStack(Blocks.GOLD_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get()) return new ItemStack(Blocks.DEEPSLATE_GOLD_ORE);
|
||||
if (block == CustomOreGenModBlocks.LAPISORE.get()) return new ItemStack(Blocks.LAPIS_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATELAPISORE.get()) return new ItemStack(Blocks.DEEPSLATE_LAPIS_ORE);
|
||||
if (block == CustomOreGenModBlocks.REDSTONEORE.get()) return new ItemStack(Blocks.REDSTONE_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get()) return new ItemStack(Blocks.DEEPSLATE_REDSTONE_ORE);
|
||||
if (block == CustomOreGenModBlocks.HIGHEMERALDORE.get()) return new ItemStack(Blocks.EMERALD_ORE);
|
||||
if (block == CustomOreGenModBlocks.LOWEREMERALDORE.get()) return new ItemStack(Blocks.DEEPSLATE_EMERALD_ORE);
|
||||
if (block == CustomOreGenModBlocks.COPPERHIGHORE.get()) return new ItemStack(Blocks.COPPER_ORE);
|
||||
if (block == CustomOreGenModBlocks.COPPERLOWERORE.get()) return new ItemStack(Blocks.DEEPSLATE_COPPER_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get()) return new ItemStack(Blocks.DEEPSLATE_DIAMOND_ORE);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private void addCustomDrops(ObjectArrayList<ItemStack> drops, String oreType, int fortuneLevel, RandomSource random) {
|
||||
DropSpec spec = DROP_SPECS.get(oreType);
|
||||
if (spec == null) return;
|
||||
|
||||
int dropCount = OreDropMath.dropCount(oreType, spec.minDrops().get(), spec.maxDrops().get(),
|
||||
spec.enableFortune().get(), fortuneLevel, random::nextInt);
|
||||
if (dropCount > 0) {
|
||||
drops.add(new ItemStack(spec.item().get(), dropCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.mixin;
|
||||
package com.aulyrius.customoregen.mixin;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.aulyrius.customoregen.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Handles the experience dropped when a player mines one of the mod's ores.
|
||||
*
|
||||
* <p>Item drops are handled separately by {@code CustomOreLootModifier} (a Global Loot
|
||||
* Modifier) so machines (Create drills, Mekanism Digital Miner, ...) also get them.
|
||||
* This procedure only spawns the XP orb, mirroring vanilla 1.21: no XP when the block
|
||||
* is harvested with Silk Touch, and no XP for non-player breakers.</p>
|
||||
*/
|
||||
public class ConfigurableOreDropsProcedure {
|
||||
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, String oreType) {
|
||||
if (world.isClientSide())
|
||||
return;
|
||||
if (!(entity instanceof Player player))
|
||||
return;
|
||||
|
||||
// Silk Touch: vanilla ores drop no XP when silk-touched
|
||||
ItemStack tool = player.getMainHandItem();
|
||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
if (tool.getEnchantmentLevel(enchantmentRegistry.getOrThrow(Enchantments.SILK_TOUCH)) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int expAmount = OreDropMath.experienceFor(oreType, new Random()::nextInt);
|
||||
if (expAmount > 0 && world instanceof ServerLevel serverLevel) {
|
||||
serverLevel.addFreshEntity(new ExperienceOrb(serverLevel, x + 0.5, y + 0.5, z + 0.5, expAmount));
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-9
@@ -1,6 +1,4 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
|
||||
import java.util.Random;
|
||||
package com.aulyrius.customoregen.procedures;
|
||||
|
||||
/**
|
||||
* Pure (Minecraft-free) ore drop math, extracted from {@link ConfigurableOreDropsProcedure}
|
||||
@@ -8,11 +6,19 @@ import java.util.Random;
|
||||
* experience calculations here, which mirrors vanilla 1.21 behaviour for the multi-drop ores
|
||||
* (Lapis, Copper, Redstone) vs the discrete ores (Diamond, Coal, Emerald).
|
||||
*
|
||||
* <p>All methods are deterministic given the {@link Random} argument, so tests can pin exact
|
||||
* outputs with a seeded {@code Random}.</p>
|
||||
* <p>All methods draw randomness through {@link IntRandom}, so they accept both
|
||||
* {@code new Random(seed)::nextInt} (deterministic unit tests) and
|
||||
* {@code lootContext.getRandom()::nextInt} (world-seeded Minecraft {@code RandomSource}).</p>
|
||||
*/
|
||||
public final class OreDropMath {
|
||||
|
||||
/** Minimal random source abstraction: compatible with both {@link java.util.Random} and
|
||||
* Minecraft's {@code RandomSource} via a {@code ::nextInt} method reference. */
|
||||
@FunctionalInterface
|
||||
public interface IntRandom {
|
||||
int nextInt(int bound);
|
||||
}
|
||||
|
||||
private OreDropMath() {}
|
||||
|
||||
/**
|
||||
@@ -29,7 +35,7 @@ public final class OreDropMath {
|
||||
* {@code minDrops + random.nextInt(maxDrops - minDrops + 1)} when {@code maxDrops > minDrops},
|
||||
* else {@code minDrops} (no-op random draw when the range is a single value).
|
||||
*/
|
||||
public static int baseDropCount(int minDrops, int maxDrops, Random random) {
|
||||
public static int baseDropCount(int minDrops, int maxDrops, IntRandom random) {
|
||||
if (maxDrops > minDrops) {
|
||||
return minDrops + random.nextInt(maxDrops - minDrops + 1);
|
||||
}
|
||||
@@ -49,7 +55,7 @@ public final class OreDropMath {
|
||||
* (and no random draw is consumed, matching the procedure guard).</p>
|
||||
*/
|
||||
public static int applyFortune(String oreType, int baseCount, boolean enableFortune,
|
||||
int fortuneLevel, Random random) {
|
||||
int fortuneLevel, IntRandom random) {
|
||||
if (!enableFortune || fortuneLevel <= 0) {
|
||||
return baseCount;
|
||||
}
|
||||
@@ -69,7 +75,7 @@ public final class OreDropMath {
|
||||
* single fortune draw).
|
||||
*/
|
||||
public static int dropCount(String oreType, int minDrops, int maxDrops,
|
||||
boolean enableFortune, int fortuneLevel, Random random) {
|
||||
boolean enableFortune, int fortuneLevel, IntRandom random) {
|
||||
int base = baseDropCount(minDrops, maxDrops, random);
|
||||
return applyFortune(oreType, base, enableFortune, fortuneLevel, random);
|
||||
}
|
||||
@@ -80,7 +86,7 @@ public final class OreDropMath {
|
||||
*
|
||||
* @return XP amount in {@code [0, max]} for the ore type, or 0 if the type does not drop XP
|
||||
*/
|
||||
public static int experienceFor(String oreType, Random random) {
|
||||
public static int experienceFor(String oreType, IntRandom random) {
|
||||
switch (oreType) {
|
||||
case "concentrated_coal":
|
||||
return random.nextInt(3); // 0-2
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.worldgen;
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.common.world.ModifiableBiomeInfo;
|
||||
|
||||
import net.mcreator.customoregen.config.ConfigHelper;
|
||||
import com.aulyrius.customoregen.config.ConfigHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+4
-10
@@ -1,6 +1,6 @@
|
||||
package net.mcreator.customoregen.worldgen;
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import com.aulyrius.customoregen.config.ModConfigs;
|
||||
|
||||
/**
|
||||
* Runtime accessor for the latitude zone thresholds.
|
||||
@@ -27,7 +27,7 @@ public final class LatitudeConfig {
|
||||
/** Z threshold below which is the cold zone. Negative = north. */
|
||||
public static int getColdZoneZ() {
|
||||
try {
|
||||
return net.mcreator.customoregen.config.ModConfigs.LATITUDE_ORE.coldZoneZ.get();
|
||||
return ModConfigs.LATITUDE_ORE.coldZoneZ.get();
|
||||
} catch (Exception e) {
|
||||
return coldZoneZ;
|
||||
}
|
||||
@@ -36,18 +36,12 @@ public final class LatitudeConfig {
|
||||
/** Z threshold above which is the hot zone. Positive = south. */
|
||||
public static int getHotZoneZ() {
|
||||
try {
|
||||
return net.mcreator.customoregen.config.ModConfigs.LATITUDE_ORE.hotZoneZ.get();
|
||||
return ModConfigs.LATITUDE_ORE.hotZoneZ.get();
|
||||
} catch (Exception e) {
|
||||
return hotZoneZ;
|
||||
}
|
||||
}
|
||||
|
||||
/** Called from the config load to update thresholds. */
|
||||
public static void update(int coldZ, int hotZ) {
|
||||
coldZoneZ = coldZ;
|
||||
hotZoneZ = hotZ;
|
||||
}
|
||||
|
||||
/** Returns a human-readable description of the zone for a given Z. */
|
||||
public static String zoneName(int z) {
|
||||
if (z < getColdZoneZ()) return "COLD";
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.worldgen;
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.util.KeyDispatchDataCodec;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.worldgen;
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/**
|
||||
* Shared "which ores generate at this Z" report, used by both the {@code /ores} command
|
||||
* and the Ore Biome Finder item (previously copy-pasted in both classes).
|
||||
*
|
||||
* <p>Each caller decides how to deliver the lines (command feedback vs client chat).</p>
|
||||
*/
|
||||
public final class OreZoneCatalog {
|
||||
|
||||
private static final List<String> COLD_ORES = List.of(
|
||||
"Lapis (stone) [Y: 0 a 32]",
|
||||
"Lapis (deepslate) [Y: -64 a 0]",
|
||||
"Diamant (deepslate) [Y: -64 a 0]");
|
||||
|
||||
private static final List<String> HOT_ORES = List.of(
|
||||
"Or (stone) [Y: 0 a 320]",
|
||||
"Or (deepslate) [Y: -64 a 0]",
|
||||
"Cuivre (haut) [Y: 15 a 320]",
|
||||
"Cuivre (bas) [Y: -64 a 0]",
|
||||
"Redstone (stone) [Y: -10 a 20]",
|
||||
"Redstone (deepslate) [Y: -80 a -30]");
|
||||
|
||||
private static final List<String> TEMPERATE_ORES = List.of(
|
||||
"Fer (stone) [Y: 0 a 100]",
|
||||
"Fer (deepslate) [Y: -64 a 0]",
|
||||
"Charbon concentre [Y: 0 a 70]");
|
||||
|
||||
private static final List<String> EVERYWHERE_ORES = List.of(
|
||||
"Diamant Shard (deepslate) [Y: -64 a -40]",
|
||||
"Bloc Diamant Shard [Y: 0 a 15]");
|
||||
|
||||
private OreZoneCatalog() {}
|
||||
|
||||
/** Ores specific to the given zone ("COLD", "HOT" or "TEMPERATE"). */
|
||||
public static List<String> oresForZone(String zone) {
|
||||
return switch (zone) {
|
||||
case "COLD" -> COLD_ORES;
|
||||
case "HOT" -> HOT_ORES;
|
||||
default -> TEMPERATE_ORES;
|
||||
};
|
||||
}
|
||||
|
||||
/** Color associated with a zone for chat output. */
|
||||
public static ChatFormatting zoneColor(String zone) {
|
||||
return switch (zone) {
|
||||
case "COLD" -> ChatFormatting.AQUA;
|
||||
case "HOT" -> ChatFormatting.GOLD;
|
||||
case "TEMPERATE" -> ChatFormatting.GREEN;
|
||||
default -> ChatFormatting.WHITE;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the full zone report (position, zone, thresholds, ore list) as chat components,
|
||||
* one per line.
|
||||
*/
|
||||
public static List<Component> buildZoneReport(int x, int z) {
|
||||
String zone = LatitudeConfig.zoneName(z);
|
||||
int coldZ = LatitudeConfig.getColdZoneZ();
|
||||
int hotZ = LatitudeConfig.getHotZoneZ();
|
||||
ChatFormatting zoneColor = zoneColor(zone);
|
||||
List<String> zoneOres = oresForZone(zone);
|
||||
|
||||
List<Component> lines = new ArrayList<>();
|
||||
lines.add(Component.literal("=== Position: X=" + x + " Z=" + z + " ===").withStyle(ChatFormatting.GRAY));
|
||||
lines.add(Component.literal("Zone determinee par la coordonnee Z : " + zone).withStyle(zoneColor));
|
||||
lines.add(Component.literal("Z < " + coldZ + " = froid | " + coldZ + " a " + hotZ + " = tempere | Z > " + hotZ + " = chaud")
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
lines.add(Component.literal("Minerais trouvables (" + (zoneOres.size() + EVERYWHERE_ORES.size()) + ") :")
|
||||
.withStyle(ChatFormatting.WHITE));
|
||||
for (String ore : zoneOres) {
|
||||
lines.add(Component.literal(" * " + ore).withStyle(zoneColor));
|
||||
}
|
||||
for (String ore : EVERYWHERE_ORES) {
|
||||
lines.add(Component.literal(" * " + ore).withStyle(ChatFormatting.LIGHT_PURPLE));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.worldgen;
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
@@ -1,88 +0,0 @@
|
||||
package net.mcreator.customoregen;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.neoforged.fml.ModContainer;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.util.thread.SidedThreadGroups;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.event.tick.ServerTickEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModTabs;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import net.mcreator.customoregen.item.ShardDiamondArmorMaterial;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import net.neoforged.fml.config.ModConfig;
|
||||
|
||||
|
||||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import net.mcreator.customoregen.loot.CustomOreLootModifier;
|
||||
import net.mcreator.customoregen.worldgen.WorldGenRegistration;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractMap;
|
||||
|
||||
@Mod(CustomOreGenMod.MODID)
|
||||
public class CustomOreGenMod {
|
||||
public static final Logger LOGGER = LogManager.getLogger(CustomOreGenMod.class);
|
||||
public static final String MODID = "custom_ore_gen";
|
||||
public static final DeferredRegister<MapCodec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, MODID);
|
||||
|
||||
public CustomOreGenMod(IEventBus modEventBus, ModContainer container) {
|
||||
// Start of user code block mod constructor
|
||||
container.registerConfig(ModConfig.Type.COMMON, ModConfigs.SPEC);
|
||||
LOOT_MODIFIERS.register("custom_ore_drops", () -> CustomOreLootModifier.CODEC);
|
||||
// End of user code block mod constructor
|
||||
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
|
||||
CustomOreGenModBlocks.REGISTRY.register(modEventBus);
|
||||
CustomOreGenModItems.REGISTRY.register(modEventBus);
|
||||
ShardDiamondArmorMaterial.REGISTRY.register(modEventBus);
|
||||
|
||||
CustomOreGenModTabs.REGISTRY.register(modEventBus);
|
||||
LOOT_MODIFIERS.register(modEventBus);
|
||||
|
||||
// Start of user code block mod init
|
||||
WorldGenRegistration.BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
WorldGenRegistration.DENSITY_FUNCTION_TYPES.register(modEventBus);
|
||||
WorldGenRegistration.PLACEMENT_MODIFIERS.register(modEventBus);
|
||||
// End of user code block mod init
|
||||
}
|
||||
|
||||
// Start of user code block mod methods
|
||||
// End of user code block mod methods
|
||||
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void queueServerWork(int tick, Runnable action) {
|
||||
if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.SERVER)
|
||||
workQueue.add(new AbstractMap.SimpleEntry<>(action, tick));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void tick(ServerTickEvent.Post event) {
|
||||
List<AbstractMap.SimpleEntry<Runnable, Integer>> actions = new ArrayList<>();
|
||||
workQueue.forEach(work -> {
|
||||
work.setValue(work.getValue() - 1);
|
||||
if (work.getValue() == 0)
|
||||
actions.add(work);
|
||||
});
|
||||
actions.forEach(e -> e.getKey().run());
|
||||
workQueue.removeAll(actions);
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package net.mcreator.customoregen;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.mcreator.customoregen.worldgen.LatitudeConfig;
|
||||
|
||||
@EventBusSubscriber(modid = CustomOreGenMod.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class OresCommand {
|
||||
|
||||
private static final List<String> COLD_ORES = Arrays.asList(
|
||||
"Lapis (stone) [Y: 0 a 32]",
|
||||
"Lapis (deepslate) [Y: -64 a 0]",
|
||||
"Diamant (deepslate) [Y: -64 a 0]");
|
||||
|
||||
private static final List<String> HOT_ORES = Arrays.asList(
|
||||
"Or (stone) [Y: 0 a 320]",
|
||||
"Or (deepslate) [Y: -64 a 0]",
|
||||
"Cuivre (haut) [Y: 15 a 320]",
|
||||
"Cuivre (bas) [Y: -64 a 0]",
|
||||
"Redstone (stone) [Y: -10 a 20]",
|
||||
"Redstone (deepslate) [Y: -80 a -30]");
|
||||
|
||||
private static final List<String> TEMPERATE_ORES = Arrays.asList(
|
||||
"Fer (stone) [Y: 0 a 100]",
|
||||
"Fer (deepslate) [Y: -64 a 0]",
|
||||
"Charbon concentre [Y: 0 a 70]");
|
||||
|
||||
private static final List<String> EVERYWHERE_ORES = Arrays.asList(
|
||||
"Diamant Shard (deepslate) [Y: -64 a -40]",
|
||||
"Bloc Diamant Shard [Y: 0 a 15]");
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterCommands(RegisterCommandsEvent event) {
|
||||
event.getDispatcher().register(Commands.literal("ores")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(OresCommand::executeOres));
|
||||
event.getDispatcher().register(Commands.literal("ore")
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(OresCommand::executeOres));
|
||||
}
|
||||
|
||||
private static int executeOres(CommandContext<CommandSourceStack> context) {
|
||||
if (!(context.getSource().getEntity() instanceof net.minecraft.world.entity.player.Player player)) {
|
||||
context.getSource().sendFailure(Component.literal("Cette commande ne peut etre utilisee que par un joueur"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x = player.blockPosition().getX();
|
||||
int z = player.blockPosition().getZ();
|
||||
|
||||
String zone = LatitudeConfig.zoneName(z);
|
||||
int coldZ = LatitudeConfig.getColdZoneZ();
|
||||
int hotZ = LatitudeConfig.getHotZoneZ();
|
||||
ChatFormatting zoneColor = zoneColor(zone);
|
||||
|
||||
context.getSource().sendSuccess(() -> Component.literal(
|
||||
"=== Position: X=" + x + " Z=" + z + " ===").withStyle(ChatFormatting.GRAY), true);
|
||||
context.getSource().sendSuccess(() -> Component.literal(
|
||||
"Zone determinee par la coordonnee Z : " + zone).withStyle(zoneColor), true);
|
||||
context.getSource().sendSuccess(() -> Component.literal(
|
||||
"Z < " + coldZ + " = froid | " + coldZ + " a " + hotZ + " = tempere | Z > " + hotZ + " = chaud")
|
||||
.withStyle(ChatFormatting.GRAY), true);
|
||||
|
||||
List<String> zoneOres = new ArrayList<>();
|
||||
switch (zone) {
|
||||
case "COLD" -> zoneOres.addAll(COLD_ORES);
|
||||
case "HOT" -> zoneOres.addAll(HOT_ORES);
|
||||
case "TEMPERATE" -> zoneOres.addAll(TEMPERATE_ORES);
|
||||
}
|
||||
|
||||
Set<String> allOres = new LinkedHashSet<>(zoneOres);
|
||||
allOres.addAll(EVERYWHERE_ORES);
|
||||
|
||||
context.getSource().sendSuccess(() -> Component.literal(
|
||||
"Minerais trouvables (" + allOres.size() + ") :").withStyle(ChatFormatting.WHITE), true);
|
||||
for (String ore : zoneOres) {
|
||||
context.getSource().sendSuccess(() -> Component.literal(" * " + ore).withStyle(zoneColor), true);
|
||||
}
|
||||
for (String ore : EVERYWHERE_ORES) {
|
||||
context.getSource().sendSuccess(() -> Component.literal(" * " + ore)
|
||||
.withStyle(ChatFormatting.LIGHT_PURPLE), true);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static ChatFormatting zoneColor(String zone) {
|
||||
return switch (zone) {
|
||||
case "COLD" -> ChatFormatting.AQUA;
|
||||
case "HOT" -> ChatFormatting.GOLD;
|
||||
case "TEMPERATE" -> ChatFormatting.GREEN;
|
||||
default -> ChatFormatting.WHITE;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
public class ConfigHelper {
|
||||
// Helper method to safely access config values
|
||||
public static boolean isFeatureEnabled(String featureName) {
|
||||
switch (featureName) {
|
||||
case "shardDiamondTools":
|
||||
return ModConfigs.FEATURES.enableShardDiamondTools.get();
|
||||
case "shardDiamondOre":
|
||||
return ModConfigs.FEATURES.enableShardDiamondOre.get();
|
||||
case "concentratedOres":
|
||||
return ModConfigs.FEATURES.enableConcentratedOres.get();
|
||||
case "impureOres":
|
||||
return ModConfigs.FEATURES.enableImpureOres.get();
|
||||
case "pureGoldenOre":
|
||||
return ModConfigs.FEATURES.enablePureGoldenOre.get();
|
||||
case "customEmeraldOres":
|
||||
return ModConfigs.FEATURES.enableCustomEmeraldOres.get();
|
||||
case "customCopperOres":
|
||||
return ModConfigs.FEATURES.enableCustomCopperOres.get();
|
||||
case "vanillaOreVariants":
|
||||
return ModConfigs.FEATURES.enableVanillaOreVariants.get();
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getShardDiamondToolDurability(String toolType) {
|
||||
switch (toolType) {
|
||||
case "pickaxe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get();
|
||||
case "axe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get();
|
||||
case "shovel":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get();
|
||||
default:
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
||||
public static float getShardDiamondToolSpeed(String toolType) {
|
||||
switch (toolType) {
|
||||
case "pickaxe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get().floatValue();
|
||||
case "axe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get().floatValue();
|
||||
case "shovel":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get().floatValue();
|
||||
default:
|
||||
return 7.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getShardDiamondToolDamage(String toolType) {
|
||||
switch (toolType) {
|
||||
case "pickaxe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondPickaxeAttackDamage.get();
|
||||
case "axe":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondAxeAttackDamage.get();
|
||||
case "shovel":
|
||||
return ModConfigs.TOOL_STATS.shardDiamondShovelAttackDamage.get();
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package net.mcreator.customoregen.event;
|
||||
|
||||
import net.neoforged.neoforge.event.level.BlockDropsEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import net.mcreator.customoregen.procedures.ConfigurableOreDropsProcedure;
|
||||
|
||||
@EventBusSubscriber
|
||||
public class OreBreakEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onBlockDrops(BlockDropsEvent event) {
|
||||
BlockState state = event.getState();
|
||||
Block block = state.getBlock();
|
||||
String oreType = getOreType(block);
|
||||
|
||||
if (oreType != null) {
|
||||
// Item drops are now handled by CustomOreLootModifier (Global Loot Modifier)
|
||||
// to ensure compatibility with machines and avoid duplication.
|
||||
|
||||
if (event.getBreaker() != null) {
|
||||
ConfigurableOreDropsProcedure.execute(event.getLevel(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), event.getBreaker(), oreType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOreType(Block block) {
|
||||
if (block == CustomOreGenModBlocks.SHARDDIAMONDBLOCKORE.get() || block == CustomOreGenModBlocks.DEEPSLATESHARDDIAMONDORE.get()) return "shard_diamond";
|
||||
if (block == CustomOreGenModBlocks.CONCENTRATEDCOALORE.get()) return "concentrated_coal";
|
||||
if (block == CustomOreGenModBlocks.PUREGOLDENORE.get() || block == CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get()) return "pure_golden";
|
||||
if (block == CustomOreGenModBlocks.IRONORE.get() || block == CustomOreGenModBlocks.DEEPSLATEIRONORE.get()) return "impure_iron";
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get()) return "concentrated_diamond";
|
||||
if (block == CustomOreGenModBlocks.LAPISORE.get() || block == CustomOreGenModBlocks.DEEPSLATELAPISORE.get()) return "lapis";
|
||||
if (block == CustomOreGenModBlocks.REDSTONEORE.get() || block == CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get()) return "redstone";
|
||||
if (block == CustomOreGenModBlocks.HIGHEMERALDORE.get() || block == CustomOreGenModBlocks.LOWEREMERALDORE.get()) return "emerald";
|
||||
if (block == CustomOreGenModBlocks.COPPERHIGHORE.get() || block == CustomOreGenModBlocks.COPPERLOWERORE.get()) return "copper";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
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 java.util.*;
|
||||
|
||||
import net.mcreator.customoregen.worldgen.LatitudeConfig;
|
||||
|
||||
public class OreBiomeFinderItem extends Item {
|
||||
|
||||
private static final List<String> COLD_ORES = Arrays.asList(
|
||||
"Lapis (stone) [Y: 0 a 32]",
|
||||
"Lapis (deepslate) [Y: -64 a 0]",
|
||||
"Diamant (deepslate) [Y: -64 a 0]");
|
||||
|
||||
private static final List<String> HOT_ORES = Arrays.asList(
|
||||
"Or (stone) [Y: 0 a 320]",
|
||||
"Or (deepslate) [Y: -64 a 0]",
|
||||
"Cuivre (haut) [Y: 15 a 320]",
|
||||
"Cuivre (bas) [Y: -64 a 0]",
|
||||
"Redstone (stone) [Y: -10 a 20]",
|
||||
"Redstone (deepslate) [Y: -80 a -30]");
|
||||
|
||||
private static final List<String> TEMPERATE_ORES = Arrays.asList(
|
||||
"Fer (stone) [Y: 0 a 100]",
|
||||
"Fer (deepslate) [Y: -64 a 0]",
|
||||
"Charbon concentre [Y: 0 a 70]");
|
||||
|
||||
private static final List<String> EVERYWHERE_ORES = Arrays.asList(
|
||||
"Diamant Shard (deepslate) [Y: -64 a -40]",
|
||||
"Bloc Diamant Shard [Y: 0 a 15]");
|
||||
|
||||
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) {
|
||||
int x = player.blockPosition().getX();
|
||||
int z = player.blockPosition().getZ();
|
||||
|
||||
String zone = LatitudeConfig.zoneName(z);
|
||||
int coldZ = LatitudeConfig.getColdZoneZ();
|
||||
int hotZ = LatitudeConfig.getHotZoneZ();
|
||||
ChatFormatting zoneColor = zoneColor(zone);
|
||||
|
||||
player.displayClientMessage(Component.literal(
|
||||
"=== Position: X=" + x + " Z=" + z + " ===").withStyle(ChatFormatting.GRAY), false);
|
||||
player.displayClientMessage(Component.literal(
|
||||
"Zone determinee par la coordonnee Z : " + zone).withStyle(zoneColor), false);
|
||||
player.displayClientMessage(Component.literal(
|
||||
"Z < " + coldZ + " = froid | " + coldZ + " a " + hotZ + " = tempere | Z > " + hotZ + " = chaud")
|
||||
.withStyle(ChatFormatting.GRAY), false);
|
||||
|
||||
List<String> zoneOres = new ArrayList<>();
|
||||
switch (zone) {
|
||||
case "COLD" -> zoneOres.addAll(COLD_ORES);
|
||||
case "HOT" -> zoneOres.addAll(HOT_ORES);
|
||||
case "TEMPERATE" -> zoneOres.addAll(TEMPERATE_ORES);
|
||||
}
|
||||
|
||||
Set<String> allOres = new LinkedHashSet<>(zoneOres);
|
||||
allOres.addAll(EVERYWHERE_ORES);
|
||||
|
||||
player.displayClientMessage(Component.literal(
|
||||
"Minerais trouvables (" + allOres.size() + ") :").withStyle(ChatFormatting.WHITE), false);
|
||||
for (String ore : zoneOres) {
|
||||
player.displayClientMessage(Component.literal(" * " + ore).withStyle(zoneColor), false);
|
||||
}
|
||||
for (String ore : EVERYWHERE_ORES) {
|
||||
player.displayClientMessage(Component.literal(" * " + ore)
|
||||
.withStyle(ChatFormatting.LIGHT_PURPLE), false);
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResultHolder.sidedSuccess(stack, level.isClientSide);
|
||||
}
|
||||
|
||||
private static ChatFormatting zoneColor(String zone) {
|
||||
return switch (zone) {
|
||||
case "COLD" -> ChatFormatting.AQUA;
|
||||
case "HOT" -> ChatFormatting.GOLD;
|
||||
case "TEMPERATE" -> ChatFormatting.GREEN;
|
||||
default -> ChatFormatting.WHITE;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.AxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondaxeItem extends AxeItem {
|
||||
public SharddiamondaxeItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeAttackDamage.get().floatValue() : 6.0f;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_AXE)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondAxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondpickaxeItem extends PickaxeItem {
|
||||
public SharddiamondpickaxeItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeAttackDamage.get().floatValue() : 1.0f;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_PICKAXE)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondPickaxeSpeed.get().floatValue() : 7.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
|
||||
package net.mcreator.customoregen.item;
|
||||
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.item.ShovelItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
|
||||
public class SharddiamondshovelItem extends ShovelItem {
|
||||
public SharddiamondshovelItem() {
|
||||
super(new Tier() {
|
||||
public int getUses() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get() : 200;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get().floatValue() : 4.0f;
|
||||
}
|
||||
|
||||
public float getAttackDamageBonus() {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelAttackDamage.get().floatValue() : 2.0f;
|
||||
}
|
||||
|
||||
public int getEnchantmentValue() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
public Ingredient getRepairIngredient() {
|
||||
return Ingredient.of(new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get()));
|
||||
}
|
||||
|
||||
// 1.21 - new method required - returns diamond-tier incorrect blocks
|
||||
public TagKey<Block> getIncorrectBlocksForDrops() {
|
||||
return BlockTags.INCORRECT_FOR_DIAMOND_TOOL;
|
||||
}
|
||||
}, new Item.Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelDurability.get() : 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
if (state.is(BlockTags.MINEABLE_WITH_SHOVEL)) {
|
||||
return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondShovelSpeed.get().floatValue() : 4.0f;
|
||||
}
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
package net.mcreator.customoregen.loot;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier;
|
||||
import net.neoforged.neoforge.common.loot.LootModifier;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
import net.mcreator.customoregen.init.CustomOreGenModBlocks;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import net.mcreator.customoregen.CustomOreGenMod;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CustomOreLootModifier extends LootModifier {
|
||||
public static final MapCodec<CustomOreLootModifier> CODEC = RecordCodecBuilder.mapCodec(inst ->
|
||||
codecStart(inst).apply(inst, CustomOreLootModifier::new)
|
||||
);
|
||||
|
||||
public CustomOreLootModifier(LootItemCondition[] conditionsIn) {
|
||||
super(conditionsIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends IGlobalLootModifier> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
|
||||
try {
|
||||
BlockState state = context.getParamOrNull(LootContextParams.BLOCK_STATE);
|
||||
if (state == null) return generatedLoot;
|
||||
|
||||
Block block = state.getBlock();
|
||||
String oreType = getOreType(block);
|
||||
|
||||
if (oreType != null) {
|
||||
ItemStack tool = context.getParamOrNull(LootContextParams.TOOL);
|
||||
|
||||
// Check for Silk Touch
|
||||
if (tool != null && !tool.isEmpty()) {
|
||||
var registry = context.getLevel().registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
int silkLevel = tool.getEnchantmentLevel(registry.getOrThrow(Enchantments.SILK_TOUCH));
|
||||
|
||||
if (silkLevel > 0) {
|
||||
// For Diamond Shard, we want to keep the modded block itself
|
||||
if (oreType.equals("shard_diamond")) {
|
||||
ObjectArrayList<ItemStack> shardLoot = new ObjectArrayList<>();
|
||||
shardLoot.add(new ItemStack(block));
|
||||
return shardLoot;
|
||||
}
|
||||
// For others, convert to vanilla block equivalent
|
||||
ItemStack vanillaBlock = getVanillaBlockDrop(block);
|
||||
if (!vanillaBlock.isEmpty()) {
|
||||
ObjectArrayList<ItemStack> silkLoot = new ObjectArrayList<>();
|
||||
silkLoot.add(vanillaBlock);
|
||||
return silkLoot;
|
||||
}
|
||||
return generatedLoot;
|
||||
}
|
||||
}
|
||||
|
||||
// If not silk touch, replace with custom drops
|
||||
ObjectArrayList<ItemStack> customDrops = new ObjectArrayList<>();
|
||||
int fortuneLevel = 0;
|
||||
if (tool != null && !tool.isEmpty()) {
|
||||
var registry = context.getLevel().registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
fortuneLevel = tool.getEnchantmentLevel(registry.getOrThrow(Enchantments.FORTUNE));
|
||||
}
|
||||
|
||||
addCustomDrops(customDrops, oreType, fortuneLevel, context.getRandom());
|
||||
|
||||
// Only return custom drops if we generated some, otherwise fallback to original
|
||||
if (!customDrops.isEmpty()) {
|
||||
return customDrops;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CustomOreGenMod.LOGGER.error("Error applying CustomOreLootModifier", e);
|
||||
}
|
||||
|
||||
return generatedLoot;
|
||||
}
|
||||
|
||||
private String getOreType(Block block) {
|
||||
if (block == CustomOreGenModBlocks.SHARDDIAMONDBLOCKORE.get() || block == CustomOreGenModBlocks.DEEPSLATESHARDDIAMONDORE.get()) return "shard_diamond";
|
||||
if (block == CustomOreGenModBlocks.CONCENTRATEDCOALORE.get()) return "concentrated_coal";
|
||||
if (block == CustomOreGenModBlocks.PUREGOLDENORE.get() || block == CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get()) return "pure_golden";
|
||||
if (block == CustomOreGenModBlocks.IRONORE.get() || block == CustomOreGenModBlocks.DEEPSLATEIRONORE.get()) return "impure_iron";
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get()) return "concentrated_diamond";
|
||||
if (block == CustomOreGenModBlocks.LAPISORE.get() || block == CustomOreGenModBlocks.DEEPSLATELAPISORE.get()) return "lapis";
|
||||
if (block == CustomOreGenModBlocks.REDSTONEORE.get() || block == CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get()) return "redstone";
|
||||
if (block == CustomOreGenModBlocks.HIGHEMERALDORE.get() || block == CustomOreGenModBlocks.LOWEREMERALDORE.get()) return "emerald";
|
||||
if (block == CustomOreGenModBlocks.COPPERHIGHORE.get() || block == CustomOreGenModBlocks.COPPERLOWERORE.get()) return "copper";
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack getVanillaBlockDrop(Block block) {
|
||||
if (block == CustomOreGenModBlocks.CONCENTRATEDCOALORE.get()) return new ItemStack(Blocks.COAL_ORE);
|
||||
if (block == CustomOreGenModBlocks.IRONORE.get()) return new ItemStack(Blocks.IRON_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEIRONORE.get()) return new ItemStack(Blocks.DEEPSLATE_IRON_ORE);
|
||||
if (block == CustomOreGenModBlocks.PUREGOLDENORE.get()) return new ItemStack(Blocks.GOLD_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEPUREGOLDENORE.get()) return new ItemStack(Blocks.DEEPSLATE_GOLD_ORE);
|
||||
if (block == CustomOreGenModBlocks.LAPISORE.get()) return new ItemStack(Blocks.LAPIS_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATELAPISORE.get()) return new ItemStack(Blocks.DEEPSLATE_LAPIS_ORE);
|
||||
if (block == CustomOreGenModBlocks.REDSTONEORE.get()) return new ItemStack(Blocks.REDSTONE_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEREDSTONEORE.get()) return new ItemStack(Blocks.DEEPSLATE_REDSTONE_ORE);
|
||||
if (block == CustomOreGenModBlocks.HIGHEMERALDORE.get()) return new ItemStack(Blocks.EMERALD_ORE);
|
||||
if (block == CustomOreGenModBlocks.LOWEREMERALDORE.get()) return new ItemStack(Blocks.DEEPSLATE_EMERALD_ORE);
|
||||
if (block == CustomOreGenModBlocks.COPPERHIGHORE.get()) return new ItemStack(Blocks.COPPER_ORE);
|
||||
if (block == CustomOreGenModBlocks.COPPERLOWERORE.get()) return new ItemStack(Blocks.DEEPSLATE_COPPER_ORE);
|
||||
if (block == CustomOreGenModBlocks.DEEPSLATEDIAMONDORE.get()) return new ItemStack(Blocks.DEEPSLATE_DIAMOND_ORE);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private void addCustomDrops(ObjectArrayList<ItemStack> drops, String oreType, int fortuneLevel, net.minecraft.util.RandomSource random) {
|
||||
int minDrops = 1;
|
||||
int maxDrops = 1;
|
||||
boolean enableFortune = true;
|
||||
ItemStack dropItem = ItemStack.EMPTY;
|
||||
|
||||
switch (oreType) {
|
||||
case "shard_diamond":
|
||||
minDrops = ModConfigs.DROPS.shardDiamondOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.shardDiamondOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.shardDiamondOreEnableFortune.get();
|
||||
dropItem = new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get());
|
||||
break;
|
||||
case "concentrated_diamond":
|
||||
minDrops = ModConfigs.DROPS.concentratedDiamondOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.concentratedDiamondOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.concentratedDiamondOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.DIAMOND);
|
||||
break;
|
||||
case "concentrated_coal":
|
||||
minDrops = ModConfigs.DROPS.concentratedCoalOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.concentratedCoalOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.concentratedCoalOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.COAL);
|
||||
break;
|
||||
case "pure_golden":
|
||||
minDrops = ModConfigs.DROPS.pureGoldenOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.pureGoldenOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.pureGoldenOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_GOLD);
|
||||
break;
|
||||
case "impure_iron":
|
||||
minDrops = ModConfigs.DROPS.impureIronOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.impureIronOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.impureIronOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_IRON);
|
||||
break;
|
||||
case "lapis":
|
||||
minDrops = ModConfigs.DROPS.lapisOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.lapisOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.lapisOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.LAPIS_LAZULI);
|
||||
break;
|
||||
case "redstone":
|
||||
minDrops = ModConfigs.DROPS.redstoneOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.redstoneOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.redstoneOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.REDSTONE);
|
||||
break;
|
||||
case "emerald":
|
||||
minDrops = ModConfigs.DROPS.emeraldOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.emeraldOreMaxDrops.get();
|
||||
dropItem = new ItemStack(Items.EMERALD);
|
||||
break;
|
||||
case "copper":
|
||||
minDrops = ModConfigs.DROPS.copperOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.copperOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.copperOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_COPPER);
|
||||
break;
|
||||
}
|
||||
|
||||
if (dropItem.isEmpty()) return;
|
||||
|
||||
int dropCount = minDrops + (maxDrops > minDrops ? random.nextInt(maxDrops - minDrops + 1) : 0);
|
||||
|
||||
if (enableFortune && fortuneLevel > 0) {
|
||||
if (oreType.equals("lapis") || oreType.equals("copper") || oreType.equals("redstone")) {
|
||||
int multiplier = random.nextInt(fortuneLevel + 2) - 1;
|
||||
if (multiplier < 0) multiplier = 0;
|
||||
dropCount *= (multiplier + 1);
|
||||
} else {
|
||||
int fortuneBonus = random.nextInt(fortuneLevel + 2) - 1;
|
||||
if (fortuneBonus < 0) fortuneBonus = 0;
|
||||
dropCount += fortuneBonus;
|
||||
}
|
||||
}
|
||||
|
||||
if (dropCount > 0) {
|
||||
dropItem.setCount(dropCount);
|
||||
drops.add(dropItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
-174
@@ -1,174 +0,0 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
|
||||
import net.mcreator.customoregen.config.ModConfigs;
|
||||
import net.mcreator.customoregen.init.CustomOreGenModItems;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ConfigurableOreDropsProcedure {
|
||||
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, String oreType) {
|
||||
if (world.isClientSide())
|
||||
return;
|
||||
|
||||
Random random = new Random();
|
||||
int fortuneLevel = 0;
|
||||
boolean silkTouch = false;
|
||||
|
||||
// Get fortune and silk touch from the tool if mining by player
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
ItemStack mainHandItem = player.getMainHandItem();
|
||||
// 1.21: Enchantment API changed - use getAllEnchantments with registry lookup
|
||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
for (Holder<Enchantment> enchantment : mainHandItem.getAllEnchantments(enchantmentRegistry).keySet()) {
|
||||
if (enchantment.is(Enchantments.FORTUNE)) {
|
||||
fortuneLevel = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment);
|
||||
}
|
||||
if (enchantment.is(Enchantments.SILK_TOUCH)) {
|
||||
silkTouch = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If silk touch, drop the block itself and return
|
||||
if (silkTouch) {
|
||||
return; // Let vanilla handle silk touch
|
||||
}
|
||||
|
||||
int minDrops = 1;
|
||||
int maxDrops = 2;
|
||||
boolean enableFortune = true;
|
||||
ItemStack dropItem = ItemStack.EMPTY;
|
||||
|
||||
// Configure drops based on ore type
|
||||
switch (oreType) {
|
||||
case "shard_diamond":
|
||||
minDrops = ModConfigs.DROPS.shardDiamondOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.shardDiamondOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.shardDiamondOreEnableFortune.get();
|
||||
dropItem = new ItemStack(CustomOreGenModItems.DIAMONDSHARD.get());
|
||||
break;
|
||||
|
||||
case "concentrated_diamond":
|
||||
minDrops = ModConfigs.DROPS.concentratedDiamondOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.concentratedDiamondOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.concentratedDiamondOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.DIAMOND);
|
||||
break;
|
||||
|
||||
case "concentrated_coal":
|
||||
minDrops = ModConfigs.DROPS.concentratedCoalOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.concentratedCoalOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.concentratedCoalOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.COAL);
|
||||
break;
|
||||
|
||||
case "pure_golden":
|
||||
minDrops = ModConfigs.DROPS.pureGoldenOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.pureGoldenOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.pureGoldenOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_GOLD);
|
||||
break;
|
||||
|
||||
case "impure_iron":
|
||||
minDrops = ModConfigs.DROPS.impureIronOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.impureIronOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.impureIronOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_IRON);
|
||||
break;
|
||||
|
||||
case "impure_gold":
|
||||
minDrops = ModConfigs.DROPS.impureGoldOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.impureGoldOreMaxDrops.get();
|
||||
dropItem = new ItemStack(Items.RAW_GOLD);
|
||||
break;
|
||||
|
||||
case "lapis":
|
||||
minDrops = ModConfigs.DROPS.lapisOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.lapisOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.lapisOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.LAPIS_LAZULI);
|
||||
break;
|
||||
|
||||
case "redstone":
|
||||
minDrops = ModConfigs.DROPS.redstoneOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.redstoneOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.redstoneOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.REDSTONE);
|
||||
break;
|
||||
|
||||
case "emerald":
|
||||
minDrops = ModConfigs.DROPS.emeraldOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.emeraldOreMaxDrops.get();
|
||||
dropItem = new ItemStack(Items.EMERALD);
|
||||
break;
|
||||
|
||||
case "copper":
|
||||
minDrops = ModConfigs.DROPS.copperOreMinDrops.get();
|
||||
maxDrops = ModConfigs.DROPS.copperOreMaxDrops.get();
|
||||
enableFortune = ModConfigs.DROPS.copperOreEnableFortune.get();
|
||||
dropItem = new ItemStack(Items.RAW_COPPER);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate base drops + fortune (pure math, unit-tested via OreDropMath)
|
||||
int dropCount = OreDropMath.dropCount(oreType, minDrops, maxDrops, enableFortune, fortuneLevel, random);
|
||||
|
||||
/*
|
||||
// ITEM DROPS ARE NOW HANDLED BY CustomLootModifier TO SUPPORT MACHINES (like Mekanism Digital Miner)
|
||||
// This avoids duplicate drops for players and ensures machines get drops.
|
||||
if (!dropItem.isEmpty() && dropCount > 0) {
|
||||
dropItem.setCount(dropCount);
|
||||
if (world instanceof ServerLevel) {
|
||||
ItemEntity itemEntity = new ItemEntity(
|
||||
(ServerLevel) world,
|
||||
x + 0.5, y + 0.5, z + 0.5,
|
||||
dropItem
|
||||
);
|
||||
itemEntity.setDefaultPickUpDelay();
|
||||
((ServerLevel) world).addFreshEntity(itemEntity);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Drop experience based on ore type (Vanilla 1.21 values, pure math in OreDropMath)
|
||||
int expAmount = 0;
|
||||
if (entity instanceof Player) {
|
||||
expAmount = OreDropMath.experienceFor(oreType, random);
|
||||
|
||||
if (expAmount > 0 && world instanceof ServerLevel) {
|
||||
ExperienceOrb expOrb = new ExperienceOrb(
|
||||
(ServerLevel) world,
|
||||
x + 0.5, y + 0.5, z + 0.5,
|
||||
expAmount
|
||||
);
|
||||
((ServerLevel) world).addFreshEntity(expOrb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
public class OreexperienceProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
// 1.21: Enchantment API changed - use getAllEnchantments with registry lookup
|
||||
boolean hasSilkTouch = false;
|
||||
if (entity instanceof LivingEntity _livEnt) {
|
||||
ItemStack mainHandItem = _livEnt.getMainHandItem();
|
||||
var enchantmentRegistry = world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
|
||||
for (Holder<Enchantment> enchantment : mainHandItem.getAllEnchantments(enchantmentRegistry).keySet()) {
|
||||
if (enchantment.is(Enchantments.SILK_TOUCH)) {
|
||||
hasSilkTouch = mainHandItem.getAllEnchantments(enchantmentRegistry).getLevel(enchantment) > 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSilkTouch) {
|
||||
// XP is now handled centrally in ConfigurableOreDropsProcedure to match Vanilla 1.21 values
|
||||
// if (world instanceof ServerLevel _level)
|
||||
// _level.addFreshEntity(new ExperienceOrb(_level, x, y, z, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,10 @@ modId="${mod_id}"
|
||||
version="${mod_version}"
|
||||
displayName="${mod_name}"
|
||||
displayURL="https://lanro.eu"
|
||||
credits="Created using mod maker MCreator - https://mcreator.net/about"
|
||||
credits="Aulyrius"
|
||||
authors="${mod_authors}"
|
||||
description='''${mod_description}'''
|
||||
|
||||
# Start of user code block mod configuration
|
||||
# End of user code block mod configuration
|
||||
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="minecraft"
|
||||
@@ -22,7 +20,6 @@ description='''${mod_description}'''
|
||||
side="BOTH"
|
||||
|
||||
|
||||
# Start of user code block dependencies configuration
|
||||
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="mr_lithosphere"
|
||||
@@ -37,7 +34,6 @@ description='''${mod_description}'''
|
||||
# data-only recipes (data/create, data/mekanism) which simply no-op if the mod is
|
||||
# absent. Declaring them here with mandatory=false + versionRange caused NeoForge to
|
||||
# fail loading when the mods were not installed (see commit history).
|
||||
# End of user code block dependencies configuration
|
||||
|
||||
# Mixin configuration
|
||||
[[mixins]]
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
|
||||
#==========================
|
||||
# Custom Ore Gem - Configuration
|
||||
#==========================
|
||||
# Ce fichier permet de personnaliser le mod Custom Ore Gem
|
||||
# Modifiez ces valeurs pour ajuster la génération des minerais, les stats des outils et plus encore!
|
||||
|
||||
|
||||
#==========================
|
||||
# Génération des Minerais
|
||||
#==========================
|
||||
[ore_generation]
|
||||
|
||||
# Configuration du Minerai d'Éclats de Diamant
|
||||
[ore_generation.shard_diamond_ore]
|
||||
# Hauteur minimale de génération (par défaut: 0)
|
||||
# Min: -64, Max: 320
|
||||
minHeight = 0
|
||||
# Hauteur maximale de génération (par défaut: 15)
|
||||
# Min: -64, Max: 320
|
||||
maxHeight = 15
|
||||
# Nombre de filons par chunk (par défaut: 1)
|
||||
# Min: 0, Max: 20
|
||||
veinsPerChunk = 1
|
||||
# Taille des filons (par défaut: 8)
|
||||
# Min: 1, Max: 32
|
||||
veinSize = 8
|
||||
|
||||
# Configuration du Minerai de Diamant Concentré
|
||||
[ore_generation.concentrated_diamond_ore]
|
||||
# Nombre de filons par chunk (par défaut: 1)
|
||||
veinsPerChunk = 1
|
||||
# Taille des filons (par défaut: 8)
|
||||
veinSize = 8
|
||||
|
||||
# Configuration du Minerai d'Or Pur
|
||||
[ore_generation.pure_golden_ore]
|
||||
# Nombre de filons par chunk (par défaut: 4)
|
||||
veinsPerChunk = 4
|
||||
# Hauteur minimale de génération (par défaut: 0)
|
||||
minHeight = 0
|
||||
# Hauteur maximale de génération (par défaut: 256)
|
||||
maxHeight = 256
|
||||
|
||||
# Configuration du Minerai de Charbon Concentré
|
||||
[ore_generation.concentrated_coal_ore]
|
||||
veinsPerChunk = 2
|
||||
|
||||
# Configuration des Minerais Impurs
|
||||
[ore_generation.impure_ores]
|
||||
# Nombre de filons de Fer Impur par chunk (par défaut: 2)
|
||||
ironVeinsPerChunk = 2
|
||||
# Nombre de filons d'Or Impur par chunk (par défaut: 2)
|
||||
goldVeinsPerChunk = 2
|
||||
|
||||
# Configuration des Minerais d'Émeraude
|
||||
[ore_generation.emerald_ores]
|
||||
# Nombre de filons de Haut Émeraude par chunk (par défaut: 1)
|
||||
highVeinsPerChunk = 1
|
||||
# Nombre de filons de Bas Émeraude par chunk (par défaut: 1)
|
||||
lowerVeinsPerChunk = 1
|
||||
|
||||
# Configuration des Minerais de Cuivre
|
||||
[ore_generation.copper_ores]
|
||||
# Nombre de filons de Haut Cuivre par chunk (par défaut: 2)
|
||||
highVeinsPerChunk = 2
|
||||
# Nombre de filons de Bas Cuivre par chunk (par défaut: 2)
|
||||
lowerVeinsPerChunk = 2
|
||||
|
||||
|
||||
#==========================
|
||||
# Stats des Outils
|
||||
#==========================
|
||||
[tool_stats]
|
||||
|
||||
# Configuration des Outils en Éclats de Diamant
|
||||
[tool_stats.shard_diamond_tools]
|
||||
# Durabilité de la Pioche (par défaut: 200)
|
||||
# Min: 1, Max: 5000
|
||||
pickaxeDurability = 200
|
||||
# Vitesse de minage de la Pioche (par défaut: 7.0)
|
||||
pickaxeSpeed = 7.0
|
||||
# Dégâts d'attaque de la Pioche (par défaut: 1)
|
||||
pickaxeAttackDamage = 1
|
||||
|
||||
# Durabilité de la Hache (par défaut: 200)
|
||||
axeDurability = 200
|
||||
# Vitesse de minage de la Hache (par défaut: 7.0)
|
||||
axeSpeed = 7.0
|
||||
# Dégâts d'attaque de la Hache (par défaut: 6)
|
||||
axeAttackDamage = 6
|
||||
|
||||
# Durabilité de la Pelle (par défaut: 200)
|
||||
shovelDurability = 200
|
||||
# Vitesse de minage de la Pelle (par défaut: 4.0)
|
||||
shovelSpeed = 4.0
|
||||
# Dégâts d'attaque de la Pelle (par défaut: 2)
|
||||
shovelAttackDamage = 2
|
||||
|
||||
|
||||
#==========================
|
||||
# Drops des Minerais
|
||||
#==========================
|
||||
[drops]
|
||||
|
||||
# Configuration du Minerai d'Éclats de Diamant
|
||||
[drops.shard_diamond_ore]
|
||||
# Nombre minimum d'éclats droppés (par défaut: 1)
|
||||
minDrops = 1
|
||||
# Nombre maximum d'éclats droppés (par défaut: 2)
|
||||
maxDrops = 2
|
||||
# Activer l'enchantement Fortune (par défaut: true)
|
||||
enableFortune = true
|
||||
|
||||
# Configuration du Minerai de Diamant Concentré
|
||||
[drops.concentrated_diamond_ore]
|
||||
# Nombre minimum de diamants droppés (par défaut: 1)
|
||||
minDrops = 1
|
||||
# Nombre maximum de diamants droppés (par défaut: 2)
|
||||
maxDrops = 2
|
||||
# Activer l'enchantement Fortune (par défaut: true)
|
||||
enableFortune = true
|
||||
|
||||
# Configuration du Minerai de Charbon Concentré
|
||||
[drops.concentrated_coal_ore]
|
||||
# Nombre minimum de charbon droppé (par défaut: 2)
|
||||
minDrops = 2
|
||||
# Nombre maximum de charbon droppé (par défaut: 4)
|
||||
maxDrops = 4
|
||||
|
||||
# Configuration du Minerai d'Or Pur
|
||||
[drops.pure_golden_ore]
|
||||
# Nombre minimum de pépites d'or droppées (par défaut: 2)
|
||||
minDrops = 2
|
||||
# Nombre maximum de pépites d'or droppées (par défaut: 4)
|
||||
maxDrops = 4
|
||||
|
||||
# Configuration du Minerai de Charbon de Cendre
|
||||
[drops.ash_coal_ore]
|
||||
# Nombre minimum de charbon de cendre droppé (par défaut: 1)
|
||||
minDrops = 1
|
||||
# Nombre maximum de charbon de cendre droppé (par défaut: 2)
|
||||
maxDrops = 2
|
||||
|
||||
# Configuration des Minerais Impurs
|
||||
[drops.impure_ores]
|
||||
# Configuration du Fer Impur
|
||||
ironMinDrops = 1
|
||||
ironMaxDrops = 2
|
||||
# Configuration de l'Or Impur
|
||||
goldMinDrops = 1
|
||||
goldMaxDrops = 2
|
||||
|
||||
# Expérience droppée par les minerais personnalisés (par défaut: 2)
|
||||
oreExperience = 2
|
||||
|
||||
|
||||
#==========================
|
||||
# Activation des Fonctionnalités
|
||||
#==========================
|
||||
[features]
|
||||
# Activer les Outils en Éclats de Diamant (par défaut: true)
|
||||
enableShardDiamondTools = true
|
||||
# Activer le Minerai d'Éclats de Diamant (par défaut: true)
|
||||
enableShardDiamondOre = true
|
||||
# Activer les Minerais Concentrés (Diamant, Charbon) (par défaut: true)
|
||||
enableConcentratedOres = true
|
||||
# Activer les Minerais Impurs (Fer, Or) (par défaut: true)
|
||||
enableImpureOres = true
|
||||
# Activer le Minerai de Charbon de Cendre (par défaut: true)
|
||||
enableAshCoalOre = true
|
||||
# Activer le Minerai d'Or Pur (par défaut: true)
|
||||
enablePureGoldenOre = true
|
||||
# Activer les Minerais d'Émeraude Personnalisés (Haut, Bas) (par défaut: true)
|
||||
enableCustomEmeraldOres = true
|
||||
# Activer les Minerais de Cuivre Personnalisés (Haut, Bas) (par défaut: true)
|
||||
enableCustomCopperOres = true
|
||||
# Activer les Variantes de Minerais Vanilla (Fer, Redstone, Lapis, etc.) (par défaut: true)
|
||||
enableVanillaOreVariants = true
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.5",
|
||||
"package": "net.mcreator.customoregen.mixin",
|
||||
"package": "com.aulyrius.customoregen.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"refmap": "custom_ore_gen.refmap.json",
|
||||
"mixins": [
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"replace": false,
|
||||
"entries": [
|
||||
"custom_ore_gen:custom_ore_drops"
|
||||
]
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen;
|
||||
package com.aulyrius.customoregen;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen;
|
||||
package com.aulyrius.customoregen;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -40,7 +40,7 @@ class OresCommandTest {
|
||||
@Test
|
||||
@DisplayName("Command class should be in correct package")
|
||||
void testCommandClass_ShouldBeInCorrectPackage() {
|
||||
assertEquals("net.mcreator.customoregen", OresCommand.class.getPackage().getName(),
|
||||
assertEquals("com.aulyrius.customoregen", OresCommand.class.getPackage().getName(),
|
||||
"OresCommand should be in correct package");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package net.mcreator.customoregen.config;
|
||||
package com.aulyrius.customoregen.config;
|
||||
|
||||
import net.mcreator.customoregen.config.ModConfigs.FeatureToggleConfig;
|
||||
import com.aulyrius.customoregen.config.ModConfigs.FeatureToggleConfig;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -104,7 +104,7 @@ class ModConfigsTest {
|
||||
@DisplayName("FeatureToggleConfig declares every toggle referenced by ConfigHelper")
|
||||
void testFeatureToggleConfig_declaresAllTogglesReferencedByConfigHelper() {
|
||||
String[] toggles = {
|
||||
"shardDiamondTools", "shardDiamondOre", "concentratedOres", "impureOres",
|
||||
"shardDiamondOre", "concentratedOres", "impureOres",
|
||||
"pureGoldenOre", "customEmeraldOres", "customCopperOres", "vanillaOreVariants"
|
||||
};
|
||||
for (String toggle : toggles) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
package com.aulyrius.customoregen.procedures;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
+31
-31
@@ -1,4 +1,4 @@
|
||||
package net.mcreator.customoregen.procedures;
|
||||
package com.aulyrius.customoregen.procedures;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -52,7 +52,7 @@ class OreDropMathTest {
|
||||
void baseDropCount_range() {
|
||||
Random rng = new Random(42L);
|
||||
for (int i = 0; i < 10_000; i++) {
|
||||
int c = OreDropMath.baseDropCount(2, 5, rng);
|
||||
int c = OreDropMath.baseDropCount(2, 5, rng::nextInt);
|
||||
assertTrue(c >= 2 && c <= 5, "out of [2,5]: " + c);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class OreDropMathTest {
|
||||
Random rng = new Random(7L);
|
||||
boolean[] seen = new boolean[10];
|
||||
for (int i = 0; i < 60_000; i++) {
|
||||
seen[OreDropMath.baseDropCount(4, 9, rng)] = true;
|
||||
seen[OreDropMath.baseDropCount(4, 9, rng::nextInt)] = true;
|
||||
}
|
||||
for (int v = 4; v <= 9; v++) {
|
||||
assertTrue(seen[v], "value " + v + " never appeared in [4,9] base draw");
|
||||
@@ -79,7 +79,7 @@ class OreDropMathTest {
|
||||
// Vanilla Emerald default: 1..1 -> always 1, and the random must NOT be consumed
|
||||
// (so that the subsequent Fortune draw lands on the same sequence).
|
||||
Random rngA = new Random(123L);
|
||||
int c = OreDropMath.baseDropCount(1, 1, rngA);
|
||||
int c = OreDropMath.baseDropCount(1, 1, rngA::nextInt);
|
||||
assertEquals(1, c);
|
||||
|
||||
// Verify no random draw happened: an identical RNG feeding dropCount()+fortune must
|
||||
@@ -102,7 +102,7 @@ class OreDropMathTest {
|
||||
// When Fortune is disabled, the RNG must not be consumed at all.
|
||||
Random rngA = new Random(999L);
|
||||
Random rngB = new Random(999L);
|
||||
int with = OreDropMath.applyFortune("shard_diamond", 3, false, 3, rngA);
|
||||
int with = OreDropMath.applyFortune("shard_diamond", 3, false, 3, rngA::nextInt);
|
||||
assertEquals(3, with);
|
||||
assertEquals(rngB.nextInt(), rngA.nextInt(),
|
||||
"disabled fortune must not consume a random draw");
|
||||
@@ -113,7 +113,7 @@ class OreDropMathTest {
|
||||
void applyFortune_zeroLevelIsNoOp() {
|
||||
Random rngA = new Random(999L);
|
||||
Random rngB = new Random(999L);
|
||||
int with = OreDropMath.applyFortune("shard_diamond", 3, true, 0, rngA);
|
||||
int with = OreDropMath.applyFortune("shard_diamond", 3, true, 0, rngA::nextInt);
|
||||
assertEquals(3, with);
|
||||
assertEquals(rngB.nextInt(), rngA.nextInt(),
|
||||
"fortune level 0 must not consume a random draw");
|
||||
@@ -131,7 +131,7 @@ class OreDropMathTest {
|
||||
Random rng = new Random(1L);
|
||||
for (int i = 0; i < 5_000; i++) {
|
||||
int base = 1 + rng.nextInt(8);
|
||||
int with = OreDropMath.applyFortune(t, base, true, fortune, rng);
|
||||
int with = OreDropMath.applyFortune(t, base, true, fortune, rng::nextInt);
|
||||
assertTrue(with >= base,
|
||||
t + " fortune=" + fortune + " base=" + base + " -> " + with + " < base");
|
||||
assertTrue(with >= 0, t + " fortune result negative: " + with);
|
||||
@@ -154,7 +154,7 @@ class OreDropMathTest {
|
||||
Random rng = new Random(t.hashCode() + fortune);
|
||||
int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
|
||||
for (int i = 0; i < 20_000; i++) {
|
||||
int with = OreDropMath.applyFortune(t, 1, true, fortune, rng);
|
||||
int with = OreDropMath.applyFortune(t, 1, true, fortune, rng::nextInt);
|
||||
// base=1, so 'with' equals 1 + bonus in [1, 1+fortune]
|
||||
assertTrue(with >= 1 && with <= 1 + fortune,
|
||||
t + " fortune=" + fortune + " with=" + with + " outside [1," + (1 + fortune) + "]");
|
||||
@@ -176,7 +176,7 @@ class OreDropMathTest {
|
||||
int[] counts = new int[5]; // index 0..4
|
||||
int n = 200_000;
|
||||
for (int i = 0; i < n; i++) {
|
||||
counts[OreDropMath.applyFortune("shard_diamond", 1, true, 3, rng)]++;
|
||||
counts[OreDropMath.applyFortune("shard_diamond", 1, true, 3, rng::nextInt)]++;
|
||||
}
|
||||
// Allow generous tolerance ±5% for RNG noise.
|
||||
assertRatio("discrete fortune III base=1 -> outcome 1 (+0)", counts[1] / (double) n, 0.40, 0.05);
|
||||
@@ -201,7 +201,7 @@ class OreDropMathTest {
|
||||
Random rng = new Random(t.hashCode() + fortune * 7);
|
||||
for (int i = 0; i < 10_000; i++) {
|
||||
int base = 4; // vanilla lapis-ish
|
||||
int with = OreDropMath.applyFortune(t, base, true, fortune, rng);
|
||||
int with = OreDropMath.applyFortune(t, base, true, fortune, rng::nextInt);
|
||||
assertTrue(with % base == 0,
|
||||
t + " multiplier result " + with + " is not a multiple of base " + base);
|
||||
assertTrue(with >= base && with <= base * (fortune + 1),
|
||||
@@ -220,7 +220,7 @@ class OreDropMathTest {
|
||||
int[] counts = new int[8];
|
||||
int n = 200_000;
|
||||
for (int i = 0; i < n; i++) {
|
||||
counts[OreDropMath.applyFortune("lapis", 1, true, 3, rng)]++;
|
||||
counts[OreDropMath.applyFortune("lapis", 1, true, 3, rng::nextInt)]++;
|
||||
}
|
||||
assertRatio("lapis multiplier fortune III -> result 1 (x1)", counts[1] / (double) n, 0.40, 0.05);
|
||||
assertRatio("lapis multiplier fortune III -> result 2 (x2)", counts[2] / (double) n, 0.20, 0.05);
|
||||
@@ -239,11 +239,11 @@ class OreDropMathTest {
|
||||
// SAME continuation of the RNG. This guards against subtle behaviour drift if a refactor
|
||||
// reorders the random draws.
|
||||
Random rngA = new Random(55L);
|
||||
int base = OreDropMath.baseDropCount(4, 9, rngA);
|
||||
int fortune = OreDropMath.applyFortune("lapis", base, true, 3, rngA);
|
||||
int base = OreDropMath.baseDropCount(4, 9, rngA::nextInt);
|
||||
int fortune = OreDropMath.applyFortune("lapis", base, true, 3, rngA::nextInt);
|
||||
|
||||
Random rngB = new Random(55L);
|
||||
int combined = OreDropMath.dropCount("lapis", 4, 9, true, 3, rngB);
|
||||
int combined = OreDropMath.dropCount("lapis", 4, 9, true, 3, rngB::nextInt);
|
||||
|
||||
assertEquals(fortune, combined, "dropCount must be base+fortune in order");
|
||||
}
|
||||
@@ -256,12 +256,12 @@ class OreDropMathTest {
|
||||
@DisplayName("XP: iron/gold/copper/unknown drop 0 raw XP")
|
||||
void experienceFor_zeroXpTypes() {
|
||||
Random rng = new Random(1L);
|
||||
assertEquals(0, OreDropMath.experienceFor("impure_iron", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("impure_gold", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("pure_golden", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("copper", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("unknown", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("", rng));
|
||||
assertEquals(0, OreDropMath.experienceFor("impure_iron", rng::nextInt));
|
||||
assertEquals(0, OreDropMath.experienceFor("impure_gold", rng::nextInt));
|
||||
assertEquals(0, OreDropMath.experienceFor("pure_golden", rng::nextInt));
|
||||
assertEquals(0, OreDropMath.experienceFor("copper", rng::nextInt));
|
||||
assertEquals(0, OreDropMath.experienceFor("unknown", rng::nextInt));
|
||||
assertEquals(0, OreDropMath.experienceFor("", rng::nextInt));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -270,24 +270,24 @@ class OreDropMathTest {
|
||||
Random rng = new Random(2L);
|
||||
// coal: 0-2
|
||||
for (int i = 0; i < 5_000; i++) {
|
||||
int xp = OreDropMath.experienceFor("concentrated_coal", rng);
|
||||
int xp = OreDropMath.experienceFor("concentrated_coal", rng::nextInt);
|
||||
assertTrue(xp >= 0 && xp <= 2, "coal XP " + xp + " out of [0,2]");
|
||||
}
|
||||
// diamond/emerald/shard: 3-7
|
||||
for (String t : new String[]{"shard_diamond", "concentrated_diamond", "emerald"}) {
|
||||
for (int i = 0; i < 5_000; i++) {
|
||||
int xp = OreDropMath.experienceFor(t, rng);
|
||||
int xp = OreDropMath.experienceFor(t, rng::nextInt);
|
||||
assertTrue(xp >= 3 && xp <= 7, t + " XP " + xp + " out of [3,7]");
|
||||
}
|
||||
}
|
||||
// lapis: 2-5
|
||||
for (int i = 0; i < 5_000; i++) {
|
||||
int xp = OreDropMath.experienceFor("lapis", rng);
|
||||
int xp = OreDropMath.experienceFor("lapis", rng::nextInt);
|
||||
assertTrue(xp >= 2 && xp <= 5, "lapis XP " + xp + " out of [2,5]");
|
||||
}
|
||||
// redstone: 1-5
|
||||
for (int i = 0; i < 5_000; i++) {
|
||||
int xp = OreDropMath.experienceFor("redstone", rng);
|
||||
int xp = OreDropMath.experienceFor("redstone", rng::nextInt);
|
||||
assertTrue(xp >= 1 && xp <= 5, "redstone XP " + xp + " out of [1,5]");
|
||||
}
|
||||
}
|
||||
@@ -300,9 +300,9 @@ class OreDropMathTest {
|
||||
boolean[] redstoneSeen = new boolean[6]; // 1..5
|
||||
boolean[] diamondSeen = new boolean[8]; // 3..7
|
||||
for (int i = 0; i < 100_000; i++) {
|
||||
coalSeen[OreDropMath.experienceFor("concentrated_coal", rng)] = true;
|
||||
redstoneSeen[OreDropMath.experienceFor("redstone", rng)] = true;
|
||||
diamondSeen[OreDropMath.experienceFor("emerald", rng)] = true;
|
||||
coalSeen[OreDropMath.experienceFor("concentrated_coal", rng::nextInt)] = true;
|
||||
redstoneSeen[OreDropMath.experienceFor("redstone", rng::nextInt)] = true;
|
||||
diamondSeen[OreDropMath.experienceFor("emerald", rng::nextInt)] = true;
|
||||
}
|
||||
for (int v = 0; v <= 2; v++) assertTrue(coalSeen[v], "coal XP " + v + " never observed");
|
||||
for (int v = 1; v <= 5; v++) assertTrue(redstoneSeen[v], "redstone XP " + v + " never observed");
|
||||
@@ -321,11 +321,11 @@ class OreDropMathTest {
|
||||
Random rngA = new Random(0xC0FFEE);
|
||||
Random rngB = new Random(0xC0FFEE);
|
||||
for (String t : oreTypes) {
|
||||
int da = OreDropMath.dropCount(t, 2, 5, true, 3, rngA);
|
||||
int db = OreDropMath.dropCount(t, 2, 5, true, 3, rngB);
|
||||
int da = OreDropMath.dropCount(t, 2, 5, true, 3, rngA::nextInt);
|
||||
int db = OreDropMath.dropCount(t, 2, 5, true, 3, rngB::nextInt);
|
||||
assertEquals(da, db, t + " dropCount diverged with same seed");
|
||||
int xa = OreDropMath.experienceFor(t, rngA);
|
||||
int xb = OreDropMath.experienceFor(t, rngB);
|
||||
int xa = OreDropMath.experienceFor(t, rngA::nextInt);
|
||||
int xb = OreDropMath.experienceFor(t, rngB::nextInt);
|
||||
assertEquals(xa, xb, t + " XP diverged with same seed");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.aulyrius.customoregen.worldgen;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Tests for the shared zone report used by the /ores command and the Ore Biome Finder item.
|
||||
*
|
||||
* Note: the default config thresholds (cold: Z < -8000, hot: Z > 8000) apply because
|
||||
* the config is not loaded in unit tests (LatitudeConfig falls back to its defaults).
|
||||
*/
|
||||
@DisplayName("OreZoneCatalog Tests")
|
||||
class OreZoneCatalogTest {
|
||||
|
||||
private static String reportText(int x, int z) {
|
||||
List<Component> report = OreZoneCatalog.buildZoneReport(x, z);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Component line : report) {
|
||||
sb.append(line.getString()).append('\n');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Cold zone report lists cold ores plus shard ores")
|
||||
void testReport_ColdZone() {
|
||||
String report = reportText(100, -10000);
|
||||
assertTrue(report.contains("COLD"), "should name the COLD zone");
|
||||
assertTrue(report.contains("Lapis"), "cold zone should list lapis");
|
||||
assertTrue(report.contains("Diamant Shard"), "everywhere ores should always be listed");
|
||||
assertFalse(report.contains("Cuivre"), "cold zone should not list hot ores");
|
||||
// 3 cold ores + 2 everywhere ores
|
||||
assertTrue(report.contains("Minerais trouvables (5)"), "should count 3 zone ores + 2 everywhere ores");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Hot zone report lists hot ores plus shard ores")
|
||||
void testReport_HotZone() {
|
||||
String report = reportText(0, 20000);
|
||||
assertTrue(report.contains("HOT"), "should name the HOT zone");
|
||||
assertTrue(report.contains("Cuivre"), "hot zone should list copper");
|
||||
assertTrue(report.contains("Redstone"), "hot zone should list redstone");
|
||||
// 6 hot ores + 2 everywhere ores
|
||||
assertTrue(report.contains("Minerais trouvables (8)"), "should count 6 zone ores + 2 everywhere ores");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Temperate zone report lists temperate ores plus shard ores")
|
||||
void testReport_TemperateZone() {
|
||||
String report = reportText(-50, 0);
|
||||
assertTrue(report.contains("TEMPERATE"), "should name the TEMPERATE zone");
|
||||
assertTrue(report.contains("Fer"), "temperate zone should list iron");
|
||||
assertFalse(report.contains("Lapis"), "temperate zone should not list cold ores");
|
||||
// 3 temperate ores + 2 everywhere ores
|
||||
assertTrue(report.contains("Minerais trouvables (5)"), "should count 3 zone ores + 2 everywhere ores");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Report includes position and zone thresholds")
|
||||
void testReport_ContainsPositionAndThresholds() {
|
||||
String report = reportText(123, -456);
|
||||
assertTrue(report.contains("X=123"), "should show the X coordinate");
|
||||
assertTrue(report.contains("Z=-456"), "should show the Z coordinate");
|
||||
assertTrue(report.contains("-8000"), "should show the cold threshold");
|
||||
assertTrue(report.contains("8000"), "should show the hot threshold");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user