neoforge stable 1.3.0+1.21.11
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package dev.sillyangel.nuggetmod;
|
||||
|
||||
public final class ExampleMod {
|
||||
public static final String MOD_ID = "nuggetmod";
|
||||
|
||||
public static void init() {
|
||||
// Write common init code here.
|
||||
}
|
||||
}
|
||||
24
common/src/main/java/dev/sillyangel/nuggetmod/NuggetMod.java
Normal file
24
common/src/main/java/dev/sillyangel/nuggetmod/NuggetMod.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package dev.sillyangel.nuggetmod;
|
||||
|
||||
import dev.sillyangel.nuggetmod.block.ModBlocks;
|
||||
import dev.sillyangel.nuggetmod.item.ModItems;
|
||||
import dev.sillyangel.nuggetmod.sound.ModSounds;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class NuggetMod {
|
||||
public static final String MOD_ID = "nuggetmod";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
public static void init() {
|
||||
LOGGER.info("Initializing Nugget Mod");
|
||||
|
||||
// Initialize registries - order matters!
|
||||
ModSounds.init();
|
||||
ModItems.init();
|
||||
ModBlocks.init();
|
||||
|
||||
LOGGER.info("Nugget Mod initialized");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package dev.sillyangel.nuggetmod.block;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ExperienceDroppingBlock;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.intprovider.UniformIntProvider;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(NuggetMod.MOD_ID, RegistryKeys.BLOCK);
|
||||
public static final DeferredRegister<Item> BLOCK_ITEMS = DeferredRegister.create(NuggetMod.MOD_ID, RegistryKeys.ITEM);
|
||||
|
||||
public static final RegistrySupplier<Block> NUGGET_BLOCK = registerBlockWithItem("nugget_block",
|
||||
() -> new Block(createBlockSettings("nugget_block")
|
||||
.strength(4f)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.AMETHYST_BLOCK)));
|
||||
|
||||
public static final RegistrySupplier<Block> RAW_NUGGET_BLOCK = registerBlockWithItem("raw_nugget_block",
|
||||
() -> new Block(createBlockSettings("raw_nugget_block")
|
||||
.strength(4f)
|
||||
.requiresTool()));
|
||||
|
||||
public static final RegistrySupplier<Block> NUGGET_ORE = registerBlockWithItem("nugget_ore",
|
||||
() -> new ExperienceDroppingBlock(UniformIntProvider.create(2, 5),
|
||||
createBlockSettings("nugget_ore")
|
||||
.strength(3f)
|
||||
.requiresTool()));
|
||||
|
||||
public static final RegistrySupplier<Block> NUGGET_DEEPSLATE_ORE = registerBlockWithItem("nugget_deepslate_ore",
|
||||
() -> new ExperienceDroppingBlock(UniformIntProvider.create(3, 6),
|
||||
createBlockSettings("nugget_deepslate_ore")
|
||||
.strength(4f)
|
||||
.requiresTool()
|
||||
.sounds(BlockSoundGroup.DEEPSLATE)));
|
||||
|
||||
private static <T extends Block> RegistrySupplier<T> registerBlockWithItem(String name, Supplier<T> block) {
|
||||
RegistrySupplier<T> toReturn = BLOCKS.register(name, block);
|
||||
BLOCK_ITEMS.register(name, () -> new BlockItem(toReturn.get(),
|
||||
new Item.Settings()
|
||||
.useBlockPrefixedTranslationKey()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(NuggetMod.MOD_ID, name)))));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static AbstractBlock.Settings createBlockSettings(String name) {
|
||||
return AbstractBlock.Settings.create()
|
||||
.registryKey(RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(NuggetMod.MOD_ID, name)));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
BLOCKS.register();
|
||||
BLOCK_ITEMS.register();
|
||||
NuggetMod.LOGGER.info("Registering Mod Blocks for " + NuggetMod.MOD_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sillyangel.nuggetmod.item;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.util.ModTags;
|
||||
import net.minecraft.item.equipment.ArmorMaterial;
|
||||
import net.minecraft.item.equipment.EquipmentAsset;
|
||||
import net.minecraft.item.equipment.EquipmentType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class ModArmorMaterials {
|
||||
static RegistryKey<? extends Registry<EquipmentAsset>> REGISTRY_KEY = RegistryKey.ofRegistry(Identifier.ofVanilla("equipment_asset"));
|
||||
public static final RegistryKey<EquipmentAsset> NUGGET_KEY = RegistryKey.of(REGISTRY_KEY, Identifier.of(NuggetMod.MOD_ID, "nugget"));
|
||||
|
||||
public static final ArmorMaterial NUGGET_ARMOR_MATERIAL = new ArmorMaterial(500, Util.make(new EnumMap<>(EquipmentType.class), map -> {
|
||||
map.put(EquipmentType.BOOTS, 3);
|
||||
map.put(EquipmentType.LEGGINGS, 6);
|
||||
map.put(EquipmentType.CHESTPLATE, 8);
|
||||
map.put(EquipmentType.HELMET, 3);
|
||||
map.put(EquipmentType.BODY, 19);
|
||||
}), 20, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE, 4.0F, 0.1F, ModTags.Items.REPAIRS_NUGGET_ARMOR, NUGGET_KEY);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.sillyangel.nuggetmod.item;
|
||||
|
||||
import net.minecraft.component.type.FoodComponent;
|
||||
|
||||
public class ModFoodComponents {
|
||||
public static final FoodComponent NUGGET = new FoodComponent.Builder()
|
||||
.nutrition(5)
|
||||
.saturationModifier(0.5f)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package dev.sillyangel.nuggetmod.item;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.sound.ModSounds;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.equipment.EquipmentType;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(NuggetMod.MOD_ID, RegistryKeys.ITEM);
|
||||
|
||||
// Basic Items
|
||||
public static final RegistrySupplier<Item> NUGGET = ITEMS.register("nugget",
|
||||
() -> new Item(createSettings("nugget").food(ModFoodComponents.NUGGET)));
|
||||
|
||||
public static final RegistrySupplier<Item> RAW_NUGGET = ITEMS.register("raw_nugget",
|
||||
() -> new Item(createSettings("raw_nugget")));
|
||||
|
||||
// Tools
|
||||
public static final RegistrySupplier<Item> NUGGET_SWORD = ITEMS.register("nugget_sword",
|
||||
() -> new Item(createSettings("nugget_sword").sword(ModToolMaterials.NUGGET, 3.0F, -2.4F)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_PICKAXE = ITEMS.register("nugget_pickaxe",
|
||||
() -> new Item(createSettings("nugget_pickaxe").pickaxe(ModToolMaterials.NUGGET, 1.0F, -2.8F)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_SHOVEL = ITEMS.register("nugget_shovel",
|
||||
() -> new ShovelItem(ModToolMaterials.NUGGET, 1.5F, -3.0F, createSettings("nugget_shovel")));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_AXE = ITEMS.register("nugget_axe",
|
||||
() -> new AxeItem(ModToolMaterials.NUGGET, 6.0F, -3.2F, createSettings("nugget_axe")));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_HOE = ITEMS.register("nugget_hoe",
|
||||
() -> new HoeItem(ModToolMaterials.NUGGET, -3.0F, 0.0F, createSettings("nugget_hoe")));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_SPEAR = ITEMS.register("nugget_spear",
|
||||
() -> new Item(createSettings("nugget_spear").spear(ModToolMaterials.NUGGET, 1F, 1.08F, 0.2F, 3.5F, 5.5F, 6.5F, 5.1F, 10.0F, 4.6F)));
|
||||
|
||||
// Armor
|
||||
public static final RegistrySupplier<Item> NUGGET_HELMET = ITEMS.register("nugget_helmet",
|
||||
() -> new Item(createSettings("nugget_helmet").armor(ModArmorMaterials.NUGGET_ARMOR_MATERIAL, EquipmentType.HELMET)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_CHESTPLATE = ITEMS.register("nugget_chestplate",
|
||||
() -> new Item(createSettings("nugget_chestplate").armor(ModArmorMaterials.NUGGET_ARMOR_MATERIAL, EquipmentType.CHESTPLATE)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_LEGGINGS = ITEMS.register("nugget_leggings",
|
||||
() -> new Item(createSettings("nugget_leggings").armor(ModArmorMaterials.NUGGET_ARMOR_MATERIAL, EquipmentType.LEGGINGS)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_BOOTS = ITEMS.register("nugget_boots",
|
||||
() -> new Item(createSettings("nugget_boots").armor(ModArmorMaterials.NUGGET_ARMOR_MATERIAL, EquipmentType.BOOTS)));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_HORSE_ARMOR = ITEMS.register("nugget_horse_armor",
|
||||
() -> new Item(createSettings("nugget_horse_armor").horseArmor(ModArmorMaterials.NUGGET_ARMOR_MATERIAL)));
|
||||
|
||||
// Special Items
|
||||
public static final RegistrySupplier<Item> NUGGET_SMITHING_TEMPLATE = ITEMS.register("nugget_armor_trim_smithing_template",
|
||||
() -> SmithingTemplateItem.of(createSettings("nugget_armor_trim_smithing_template")));
|
||||
|
||||
public static final RegistrySupplier<Item> NUGGET_MUSIC_DISC = ITEMS.register("nugget_music_disc",
|
||||
() -> new Item(createSettings("nugget_music_disc").jukeboxPlayable(ModSounds.NUGGET_THEME_KEY).maxCount(1)));
|
||||
|
||||
private static Item.Settings createSettings(String name) {
|
||||
return new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(NuggetMod.MOD_ID, name)));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
ITEMS.register();
|
||||
NuggetMod.LOGGER.info("Registering Mod Items for " + NuggetMod.MOD_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sillyangel.nuggetmod.item;
|
||||
|
||||
import dev.sillyangel.nuggetmod.util.ModTags;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
|
||||
public class ModToolMaterials {
|
||||
public static final ToolMaterial NUGGET = new ToolMaterial(
|
||||
ModTags.Blocks.INCORRECT_FOR_NUGGET_TOOL,
|
||||
1500,
|
||||
8.0F,
|
||||
3.5F,
|
||||
22,
|
||||
ModTags.Items.NUGGET_TOOL_MATERIALS
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.sillyangel.nuggetmod.sound;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.block.jukebox.JukeboxSong;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ModSounds {
|
||||
public static final DeferredRegister<SoundEvent> SOUND_EVENTS = DeferredRegister.create(NuggetMod.MOD_ID, RegistryKeys.SOUND_EVENT);
|
||||
|
||||
public static final RegistrySupplier<SoundEvent> NUGGET_THEME = SOUND_EVENTS.register("nugget_theme",
|
||||
() -> SoundEvent.of(Identifier.of(NuggetMod.MOD_ID, "nugget_theme")));
|
||||
|
||||
public static final RegistryKey<JukeboxSong> NUGGET_THEME_KEY =
|
||||
RegistryKey.of(RegistryKeys.JUKEBOX_SONG, Identifier.of(NuggetMod.MOD_ID, "nugget_theme"));
|
||||
|
||||
public static void init() {
|
||||
SOUND_EVENTS.register();
|
||||
NuggetMod.LOGGER.info("Registering Mod Sounds for " + NuggetMod.MOD_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package dev.sillyangel.nuggetmod.trim;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.item.ModItems;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.equipment.trim.ArmorTrimAssets;
|
||||
import net.minecraft.item.equipment.trim.ArmorTrimMaterial;
|
||||
import net.minecraft.registry.Registerable;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
|
||||
public class ModTrimMaterials {
|
||||
public static final RegistryKey<ArmorTrimMaterial> NUGGET = RegistryKey.of(RegistryKeys.TRIM_MATERIAL,
|
||||
Identifier.of(NuggetMod.MOD_ID, "nugget"));
|
||||
|
||||
public static void bootstrap(Registerable<ArmorTrimMaterial> registerable) {
|
||||
register(registerable, NUGGET, Registries.ITEM.getEntry(ModItems.NUGGET.get()),
|
||||
Style.EMPTY.withColor(TextColor.parse("#f9b042").getOrThrow()));
|
||||
|
||||
}
|
||||
|
||||
private static void register(Registerable<ArmorTrimMaterial> registerable, RegistryKey<ArmorTrimMaterial> armorTrimKey,
|
||||
RegistryEntry<Item> item, Style style) {
|
||||
ArmorTrimMaterial trimMaterial = new ArmorTrimMaterial(ArmorTrimAssets.of("nugget"),
|
||||
Text.translatable(Util.createTranslationKey("trim_material", armorTrimKey.getValue())).fillStyle(style));
|
||||
|
||||
registerable.register(armorTrimKey, trimMaterial);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package dev.sillyangel.nuggetmod.trim;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.item.ModItems;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.equipment.trim.ArmorTrimPattern;
|
||||
import net.minecraft.registry.Registerable;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
public class ModTrimPatterns {
|
||||
public static final RegistryKey<ArmorTrimPattern> NUGGET = RegistryKey.of(RegistryKeys.TRIM_PATTERN,
|
||||
Identifier.of(NuggetMod.MOD_ID, "nugget"));
|
||||
|
||||
public static void bootstrap(Registerable<ArmorTrimPattern> context) {
|
||||
register(context, ModItems.NUGGET_SMITHING_TEMPLATE.get(), NUGGET);
|
||||
}
|
||||
|
||||
private static void register(Registerable<ArmorTrimPattern> context, Item item, RegistryKey<ArmorTrimPattern> key) {
|
||||
ArmorTrimPattern trimPattern = new ArmorTrimPattern(key.getValue(),
|
||||
Text.translatable(Util.createTranslationKey("trim_pattern", key.getValue())), false);
|
||||
|
||||
context.register(key, trimPattern);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.sillyangel.nuggetmod.util;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ModTags {
|
||||
public static class Blocks {
|
||||
public static final TagKey<Block> NEEDS_NUGGET_TOOL = createTag("needs_nugget_tool");
|
||||
public static final TagKey<Block> INCORRECT_FOR_NUGGET_TOOL = createTag("incorrect_for_nugget_tool");
|
||||
|
||||
private static TagKey<Block> createTag(String name) {
|
||||
return TagKey.of(RegistryKeys.BLOCK, Identifier.of(NuggetMod.MOD_ID, name));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Items {
|
||||
public static final TagKey<Item> NUGGET_TOOL_MATERIALS = createTag("nugget_tool_materials");
|
||||
public static final TagKey<Item> REPAIRS_NUGGET_ARMOR = createTag("repairs_nugget_armor");
|
||||
|
||||
private static TagKey<Item> createTag(String name) {
|
||||
return TagKey.of(RegistryKeys.ITEM, Identifier.of(NuggetMod.MOD_ID, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package dev.sillyangel.nuggetmod.worldgen;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.block.ModBlocks;
|
||||
import net.minecraft.registry.Registerable;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.structure.rule.RuleTest;
|
||||
import net.minecraft.structure.rule.TagMatchRuleTest;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModConfiguredFeatures {
|
||||
public static final RegistryKey<ConfiguredFeature<?, ?>> NUGGET_ORE_KEY = registerKey("nugget_ore");
|
||||
|
||||
public static void bootstrap(Registerable<ConfiguredFeature<?, ?>> context) {
|
||||
RuleTest stoneReplaceables = new TagMatchRuleTest(BlockTags.STONE_ORE_REPLACEABLES);
|
||||
RuleTest deepslateReplaceables = new TagMatchRuleTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
|
||||
|
||||
List<OreFeatureConfig.Target> overworldNuggetOres =
|
||||
List.of(OreFeatureConfig.createTarget(stoneReplaceables, ModBlocks.NUGGET_ORE.get().getDefaultState()),
|
||||
OreFeatureConfig.createTarget(deepslateReplaceables, ModBlocks.NUGGET_DEEPSLATE_ORE.get().getDefaultState()));
|
||||
|
||||
register(context, NUGGET_ORE_KEY, Feature.ORE, new OreFeatureConfig(overworldNuggetOres, 12));
|
||||
}
|
||||
|
||||
public static RegistryKey<ConfiguredFeature<?, ?>> registerKey(String name) {
|
||||
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(NuggetMod.MOD_ID, name));
|
||||
}
|
||||
|
||||
private static <FC extends FeatureConfig, F extends Feature<FC>> void register(Registerable<ConfiguredFeature<?, ?>> context,
|
||||
RegistryKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) {
|
||||
context.register(key, new ConfiguredFeature<>(feature, configuration));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.sillyangel.nuggetmod.worldgen;
|
||||
|
||||
import net.minecraft.world.gen.placementmodifier.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModOrePlacement {
|
||||
public static List<PlacementModifier> modifiers(PlacementModifier countModifier, PlacementModifier heightModifier) {
|
||||
return List.of(countModifier, SquarePlacementModifier.of(), heightModifier, BiomePlacementModifier.of());
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> modifiersWithCount(int count, PlacementModifier heightModifier) {
|
||||
return modifiers(CountPlacementModifier.of(count), heightModifier);
|
||||
}
|
||||
|
||||
public static List<PlacementModifier> modifiersWithRarity(int chance, PlacementModifier heightModifier) {
|
||||
return modifiers(RarityFilterPlacementModifier.of(chance), heightModifier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package dev.sillyangel.nuggetmod.worldgen;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.registry.Registerable;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.gen.YOffset;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.PlacedFeature;
|
||||
import net.minecraft.world.gen.placementmodifier.HeightRangePlacementModifier;
|
||||
import net.minecraft.world.gen.placementmodifier.PlacementModifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModPlacedFeatures {
|
||||
public static final RegistryKey<PlacedFeature> NUGGET_ORE_PLACED_KEY = registerKey("nugget_ore_placed");
|
||||
// public static final RegistryKey<PlacedFeature> NETHER_NUGGET_ORE_PLACED_KEY = registerKey("nether_nugget_ore_placed");
|
||||
// public static final RegistryKey<PlacedFeature> END_NUGGET_ORE_PLACED_KEY = registerKey("end_nugget_ore_placed");
|
||||
|
||||
public static void bootstrap(Registerable<PlacedFeature> context) {
|
||||
var configuredFeatures = context.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE);
|
||||
|
||||
register(context, NUGGET_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.NUGGET_ORE_KEY),
|
||||
ModOrePlacement.modifiersWithCount(14,
|
||||
HeightRangePlacementModifier.uniform(YOffset.fixed(-64), YOffset.fixed(80))));
|
||||
// register(context, NETHER_NUGGET_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.NETHER_NUGGET_ORE_KEY),
|
||||
// ModOrePlacement.modifiersWithCount(14,
|
||||
// HeightRangePlacementModifier.uniform(YOffset.fixed(-80), YOffset.fixed(80))));
|
||||
// register(context, END_NUGGET_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.END_NUGGET_ORE_KEY),
|
||||
// ModOrePlacement.modifiersWithCount(14,
|
||||
// HeightRangePlacementModifier.uniform(YOffset.fixed(-80), YOffset.fixed(80))));
|
||||
|
||||
}
|
||||
|
||||
public static RegistryKey<PlacedFeature> registerKey(String name) {
|
||||
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(NuggetMod.MOD_ID, name));
|
||||
}
|
||||
|
||||
private static void register(Registerable<PlacedFeature> context, RegistryKey<PlacedFeature> key, RegistryEntry<ConfiguredFeature<?, ?>> configuration,
|
||||
List<PlacementModifier> modifiers) {
|
||||
context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers)));
|
||||
}
|
||||
|
||||
private static <FC extends FeatureConfig, F extends Feature<FC>> void register(Registerable<PlacedFeature> context, RegistryKey<PlacedFeature> key,
|
||||
RegistryEntry<ConfiguredFeature<?, ?>> configuration,
|
||||
PlacementModifier... modifiers) {
|
||||
register(context, key, configuration, List.of(modifiers));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user