-
Notifications
You must be signed in to change notification settings - Fork 0
Utilities
I'll examine the utilities directory to understand the available utility classes and create comprehensive documentation.
The Temporal API provides a comprehensive set of utility classes that streamline common operations in Minecraft mod development. These utilities handle resource management, reflection, registry operations, and world generation tasks, reducing boilerplate code and providing consistent patterns across the framework.
The utility classes serve as foundational helpers for:
- Resource location management - parsing and creating ResourceLocation objects
- Registry operations - accessing and manipulating Minecraft registries
- Reflection utilities - dynamic class inspection and method invocation
- Tag management - creating and organizing tag keys
- Map operations - specialized map manipulation methods
- World generation - placement modifiers and feature registration
- Enum extensions - supporting dynamic enum-like structures
Each utility class focuses on a specific domain and provides static methods for common operations. The utilities are designed to be stateless and thread-safe, using only their input parameters and returning new objects or primitives without maintaining internal state.
- ResourceUtils: Handles resource location parsing, creation, and mapping
- RegistryUtils: Provides typed access to Minecraft registries
- ReflectionUtils: Offers safe reflection operations with proper exception handling
- TagUtils: Creates and manages tag keys for various registry types
- MapUtils: Supplies specialized map manipulation methods
- WorldGenerationUtils: Simplifies world generation feature setup
- EnumExtensionUtils: Supports dynamic enum-like data structures
// Parse resource locations
ResourceLocation mclocation = ResourceUtils.parse("minecraft:example");
ResourceLocation modLocation = ResourceUtils.parse("yourmodid:example"); // or just "example" without mod id
// Create resource keys
ResourceKey<Item> itemKey = ResourceUtils.createKey(Registries.ITEM, "my_item");// Get registry objects
Block stoneBlock = RegistryUtils.getBlock("minecraft:stone");
Item diamondItem = RegistryUtils.getItem("minecraft:diamond");
SoundEvent sound = RegistryUtils.getSoundEvent("minecraft:ambient.cave");
// Filter registry objects
Stream<Block> allBlocks = RegistryUtils.getObjectsByCondition(
BuiltInRegistries.BLOCK,
block -> block.defaultBlockState().isAir()
);
// Get object IDs
String blockId = RegistryUtils.getObjectId(BuiltInRegistries.BLOCK, stoneBlock);// Create tag keys
TagKey<Block> blockTag = TagUtils.createBlock("custom_blocks");
TagKey<Item> itemTag = TagUtils.createItem("custom_items");
TagKey<Biome> biomeTag = TagUtils.createBiome("spawn_biomes");
// Generic tag creation
TagKey<EntityType<?>> entityTag = TagUtils.createTag(Registries.ENTITY_TYPE, "entities");
### World Generation
```java
// Ore placement
List<PlacementModifier> commonOre = WorldGenerationUtils.createCommonOrePlacement(
8,
HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(64))
);
List<PlacementModifier> rareOre = WorldGenerationUtils.createRareOrePlacement(
4,
HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.absolute(32))
);
// Custom placement
List<PlacementModifier> customPlacement = WorldGenerationUtils.createOrePlacement(
CountPlacement.of(10),
HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.top())
);
// Register features
WorldGenerationUtils.registerFeature(
context,
featureKey,
Feature.ORE,
new OreConfiguration(targetStates, size)
);
- Resource location parsing - Always use ResourceUtils instead of manual string splitting
- Registry access - Prefer RegistryUtils for type-safe registry operations
- Tag creation - Use TagUtils for consistent tag key creation
- World generation setup - Use WorldGenerationUtils for standard placement patterns
The utilities are designed to reduce boilerplate and provide consistency, but should not replace standard Java operations when they are more appropriate for the specific use case.
For more, check the util package!
🚀 Getting Started
🧩 Core Concepts
⚙️ Data Generation
- ⚙️ Advancement
- ⚙️ Damage Type
- ⚙️ Chest Loot Modifier
- ⚙️ Recipe
- ⚙️ Sound
- ⚙️ Jukebox Song
- ⚙️ Enchantment
- ⚙️ Trim Material
- ⚙️ Trim Pattern
- ⚙️ Banner Pattern
- ⚙️ Painting Variant
- ⚙️ Particle Sprite Set
- ⚙️ Wolf Variant
- ⚙️ Item Model
- ⚙️ Block Model
- ⚙️ Block Loot Table
- ⚙️ Tag
- ⚙️ Language Translation
- ⚙️ World Feature
- ⚙️ Custom Properties
🚨 Events
🛠 Engine Layers
🧪 Resources
- 🧪 Examples