fabric & neoforge stable 1.3.1+1.21.11
All checks were successful
Build and Artifact / build (push) Successful in 2m46s
All checks were successful
Build and Artifact / build (push) Successful in 2m46s
This commit is contained in:
@@ -3,17 +3,18 @@ package dev.sillyangel.nuggetmod.neoforge;
|
||||
import dev.sillyangel.nuggetmod.neoforge.item.ModItemGroups;
|
||||
import dev.sillyangel.nuggetmod.neoforge.particle.ModParticles;
|
||||
import dev.sillyangel.nuggetmod.neoforge.villager.ModVillagers;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
@Mod(dev.sillyangel.nuggetmod.NuggetMod.MOD_ID)
|
||||
public final class NuggetMod {
|
||||
public NuggetMod() {
|
||||
public NuggetMod(IEventBus modEventBus) {
|
||||
// Run our common setup.
|
||||
dev.sillyangel.nuggetmod.NuggetMod.init();
|
||||
|
||||
// Register NeoForge-specific features
|
||||
ModParticles.registerParticles();
|
||||
ModVillagers.registerVillagers();
|
||||
ModItemGroups.registerItemGroups();
|
||||
ModParticles.registerParticles(modEventBus);
|
||||
ModVillagers.registerVillagers(modEventBus);
|
||||
ModItemGroups.registerItemGroups(modEventBus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class NuggetModClient {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerParticleFactories(RegisterParticleProvidersEvent event) {
|
||||
event.registerSpriteSet(ModParticles.NUGGET_PARTICLE, NuggetParticle.Factory::new);
|
||||
event.registerSpriteSet(ModParticles.NUGGET_PARTICLE.get(), NuggetParticle.Factory::new);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package dev.sillyangel.nuggetmod.neoforge.event;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import dev.sillyangel.nuggetmod.item.ModItems;
|
||||
import dev.sillyangel.nuggetmod.neoforge.villager.ModVillagers;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.village.TradedItem;
|
||||
import net.minecraft.village.VillagerProfession;
|
||||
import net.minecraft.village.TradeOffer;
|
||||
import net.minecraft.village.TradeOffers;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.village.VillagerTradesEvent;
|
||||
import net.neoforged.neoforge.event.village.WandererTradesEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EventBusSubscriber(modid = NuggetMod.MOD_ID)
|
||||
public class ModEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void addCustomTrades(VillagerTradesEvent event) {
|
||||
// Add trades to vanilla FARMER profession
|
||||
if(event.getType() == VillagerProfession.FARMER) {
|
||||
Int2ObjectMap<List<TradeOffers.Factory>> trades = event.getTrades();
|
||||
|
||||
trades.get(1).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 3),
|
||||
new ItemStack(ModItems.NUGGET.get(), 8), 7, 2, 0.04f));
|
||||
}
|
||||
|
||||
// Add trades to custom NUGGETER profession
|
||||
if(event.getType().equals(ModVillagers.NUGGETER_KEY)) {
|
||||
Int2ObjectMap<List<TradeOffers.Factory>> trades = event.getTrades();
|
||||
|
||||
// Level 1 trades
|
||||
trades.get(1).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 5),
|
||||
new ItemStack(ModItems.NUGGET.get(), 20), 4, 7, 0.04f));
|
||||
|
||||
trades.get(1).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.DIAMOND, 2),
|
||||
new ItemStack(ModItems.RAW_NUGGET.get(), 12), 6, 5, 0.05f));
|
||||
|
||||
// Level 2 trades
|
||||
trades.get(2).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.GOLD_INGOT, 8),
|
||||
new ItemStack(ModItems.NUGGET_SWORD.get(), 1), 3, 10, 0.05f));
|
||||
|
||||
trades.get(2).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 10),
|
||||
new ItemStack(ModItems.NUGGET_PICKAXE.get(), 1), 3, 10, 0.05f));
|
||||
|
||||
// Level 3 trades
|
||||
trades.get(3).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 15),
|
||||
new ItemStack(ModItems.NUGGET_HELMET.get(), 1), 2, 15, 0.05f));
|
||||
|
||||
trades.get(3).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 20),
|
||||
new ItemStack(ModItems.NUGGET_CHESTPLATE.get(), 1), 2, 15, 0.05f));
|
||||
|
||||
// Level 4 trades
|
||||
trades.get(4).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.DIAMOND, 5),
|
||||
new ItemStack(ModItems.NUGGET_LEGGINGS.get(), 1), 2, 20, 0.05f));
|
||||
|
||||
trades.get(4).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 12),
|
||||
new ItemStack(ModItems.NUGGET_BOOTS.get(), 1), 2, 20, 0.05f));
|
||||
|
||||
// Level 5 trades (Master)
|
||||
trades.get(5).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 30),
|
||||
new ItemStack(ModItems.NUGGET_HORSE_ARMOR.get(), 1), 1, 30, 0.1f));
|
||||
|
||||
trades.get(5).add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.DIAMOND, 10),
|
||||
new ItemStack(ModItems.NUGGET_SMITHING_TEMPLATE.get(), 1), 1, 30, 0.1f));
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void addWanderingTrades(WandererTradesEvent event) {
|
||||
List<TradeOffers.Factory> genericTrades = event.getGenericTrades();
|
||||
List<TradeOffers.Factory> rareTrades = event.getRareTrades();
|
||||
|
||||
// Add generic wandering trader trades
|
||||
genericTrades.add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 12),
|
||||
new ItemStack(ModItems.NUGGET.get(), 3), 2, 8, 0.2f));
|
||||
|
||||
// Add rare wandering trader trades
|
||||
rareTrades.add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.DIAMOND, 8),
|
||||
new ItemStack(ModItems.NUGGET_MUSIC_DISC.get(), 1), 1, 12, 0.2f));
|
||||
|
||||
rareTrades.add((level, entity, random) -> new TradeOffer(
|
||||
new TradedItem(Items.EMERALD, 25),
|
||||
new ItemStack(ModItems.NUGGET_SMITHING_TEMPLATE.get(), 1), 1, 12, 0.2f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,20 @@ import dev.sillyangel.nuggetmod.block.ModBlocks;
|
||||
import dev.sillyangel.nuggetmod.item.ModItems;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModItemGroups {
|
||||
public static final DeferredRegister<ItemGroup> CREATIVE_MODE_TABS =
|
||||
DeferredRegister.create(RegistryKeys.ITEM_GROUP, NuggetMod.MOD_ID);
|
||||
|
||||
public static final RegistryKey<ItemGroup> NUGGET_BLOCKS_GROUP_KEY = RegistryKey.of(RegistryKeys.ITEM_GROUP,
|
||||
Identifier.of(NuggetMod.MOD_ID, "nugget_blocks"));
|
||||
|
||||
public static final ItemGroup NUGGET_BLOCKS_GROUP = Registry.register(Registries.ITEM_GROUP,
|
||||
NUGGET_BLOCKS_GROUP_KEY,
|
||||
ItemGroup.create(ItemGroup.Row.TOP, -1)
|
||||
public static final Supplier<ItemGroup> NUGGET_BLOCKS_GROUP = CREATIVE_MODE_TABS.register("nugget_blocks",
|
||||
() -> ItemGroup.create(ItemGroup.Row.TOP, -1)
|
||||
.icon(() -> new ItemStack(ModBlocks.NUGGET_BLOCK.get()))
|
||||
.displayName(Text.translatable("creativetab.nuggetmod.nugget_blocks"))
|
||||
.entries((displayContext, entries) -> {
|
||||
@@ -29,13 +28,10 @@ public class ModItemGroups {
|
||||
entries.add(ModBlocks.NUGGET_DEEPSLATE_ORE.get());
|
||||
}).build());
|
||||
|
||||
public static final RegistryKey<ItemGroup> NUGGET_ITEMS_GROUP_KEY = RegistryKey.of(RegistryKeys.ITEM_GROUP,
|
||||
Identifier.of(NuggetMod.MOD_ID, "nugget_items"));
|
||||
|
||||
public static final ItemGroup NUGGET_ITEMS_GROUP = Registry.register(Registries.ITEM_GROUP,
|
||||
NUGGET_ITEMS_GROUP_KEY,
|
||||
ItemGroup.create(ItemGroup.Row.TOP, -1)
|
||||
public static final Supplier<ItemGroup> NUGGET_ITEMS_GROUP = CREATIVE_MODE_TABS.register("nugget_items",
|
||||
() -> ItemGroup.create(ItemGroup.Row.TOP, -1)
|
||||
.icon(() -> new ItemStack(ModItems.NUGGET.get()))
|
||||
.withTabsBefore(Identifier.of(NuggetMod.MOD_ID, "nugget_blocks"))
|
||||
.displayName(Text.translatable("creativetab.nuggetmod.nugget_items"))
|
||||
.entries((displayContext, entries) -> {
|
||||
entries.add(ModItems.NUGGET.get());
|
||||
@@ -58,7 +54,8 @@ public class ModItemGroups {
|
||||
entries.add(ModItems.NUGGET_MUSIC_DISC.get());
|
||||
}).build());
|
||||
|
||||
public static void registerItemGroups() {
|
||||
public static void registerItemGroups(IEventBus eventBus) {
|
||||
CREATIVE_MODE_TABS.register(eventBus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package dev.sillyangel.nuggetmod.neoforge.particle;
|
||||
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModParticles {
|
||||
public static final SimpleParticleType NUGGET_PARTICLE =
|
||||
registerParticle("nugget_particle", new SimpleParticleType(false));
|
||||
public static final DeferredRegister<net.minecraft.particle.ParticleType<?>> PARTICLE_TYPES =
|
||||
DeferredRegister.create(RegistryKeys.PARTICLE_TYPE, NuggetMod.MOD_ID);
|
||||
|
||||
private static SimpleParticleType registerParticle(String name, SimpleParticleType particleType) {
|
||||
return Registry.register(Registries.PARTICLE_TYPE, Identifier.of(NuggetMod.MOD_ID, name), particleType);
|
||||
}
|
||||
public static final Supplier<net.minecraft.particle.SimpleParticleType> NUGGET_PARTICLE =
|
||||
PARTICLE_TYPES.register("nugget_particle", () -> new net.minecraft.particle.SimpleParticleType(false));
|
||||
|
||||
public static void registerParticles() {
|
||||
public static void registerParticles(IEventBus eventBus) {
|
||||
PARTICLE_TYPES.register(eventBus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ import net.minecraft.util.math.random.Random;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NuggetParticle extends BillboardParticle {
|
||||
public NuggetParticle(ClientWorld clientWorld, double x, double y, double z,
|
||||
SpriteProvider spriteProvider, double xSpeed, double ySpeed, double zSpeed) {
|
||||
super(clientWorld, x, y, z, xSpeed, ySpeed, zSpeed, spriteProvider.getFirst());
|
||||
protected NuggetParticle(ClientWorld level, double x, double y, double z, SpriteProvider spriteSet,
|
||||
double xSpeed, double ySpeed, double zSpeed) {
|
||||
super(level, x, y, z, xSpeed, ySpeed, zSpeed, spriteSet.getSprite(Random.create()));
|
||||
|
||||
this.velocityMultiplier = 0.8f;
|
||||
this.maxAge = 40;
|
||||
this.maxAge = 80;
|
||||
|
||||
this.red = 1f;
|
||||
this.green = 1f;
|
||||
this.blue = 1f;
|
||||
@@ -24,17 +25,17 @@ public class NuggetParticle extends BillboardParticle {
|
||||
}
|
||||
|
||||
public static class Factory implements ParticleFactory<SimpleParticleType> {
|
||||
private final SpriteProvider spriteProvider;
|
||||
private final SpriteProvider spriteSet;
|
||||
|
||||
public Factory(SpriteProvider spriteProvider) {
|
||||
this.spriteProvider = spriteProvider;
|
||||
public Factory(SpriteProvider spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z,
|
||||
double velocityX, double velocityY, double velocityZ, Random random) {
|
||||
return new NuggetParticle(world, x, y, z, this.spriteProvider, velocityX, velocityY, velocityZ);
|
||||
public Particle createParticle(SimpleParticleType simpleParticleType, ClientWorld clientLevel,
|
||||
double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed, Random randomSource) {
|
||||
return new NuggetParticle(clientLevel, pX, pY, pZ, this.spriteSet, pXSpeed, pYSpeed, pZSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ package dev.sillyangel.nuggetmod.neoforge.villager;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import dev.sillyangel.nuggetmod.NuggetMod;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import dev.sillyangel.nuggetmod.block.ModBlocks;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
@@ -11,26 +10,33 @@ import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.village.VillagerProfession;
|
||||
import net.minecraft.world.poi.PointOfInterestType;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModVillagers {
|
||||
public static final RegistryKey<PointOfInterestType> NUGGETER_POI_KEY = registerPoiKey("nuggeter_poi");
|
||||
public static final DeferredRegister<PointOfInterestType> POI_TYPES =
|
||||
DeferredRegister.create(RegistryKeys.POINT_OF_INTEREST_TYPE, NuggetMod.MOD_ID);
|
||||
public static final DeferredRegister<VillagerProfession> VILLAGER_PROFESSIONS =
|
||||
DeferredRegister.create(RegistryKeys.VILLAGER_PROFESSION, NuggetMod.MOD_ID);
|
||||
|
||||
public static final RegistryKey<VillagerProfession> NUGGETER_KEY =
|
||||
RegistryKey.of(RegistryKeys.VILLAGER_PROFESSION, Identifier.of(NuggetMod.MOD_ID, "nuggeter"));
|
||||
|
||||
public static final VillagerProfession NUGGETER = registerProfession("nuggeter", NUGGETER_POI_KEY);
|
||||
public static final Supplier<PointOfInterestType> NUGGETER_POI = POI_TYPES.register("nuggeter_poi",
|
||||
() -> new PointOfInterestType(ImmutableSet.copyOf(ModBlocks.NUGGET_BLOCK.get().getStateManager().getStates()), 1, 1));
|
||||
|
||||
private static VillagerProfession registerProfession(String name, RegistryKey<PointOfInterestType> type) {
|
||||
return Registry.register(Registries.VILLAGER_PROFESSION, Identifier.of(NuggetMod.MOD_ID, name),
|
||||
new VillagerProfession(Text.literal("Nuggeter"), entry -> entry.matchesKey(type), entry -> entry.matchesKey(type),
|
||||
ImmutableSet.of(), ImmutableSet.of(), SoundEvents.ENTITY_VILLAGER_WORK_LIBRARIAN));
|
||||
}
|
||||
public static final Supplier<VillagerProfession> NUGGETER = VILLAGER_PROFESSIONS.register("nuggeter",
|
||||
() -> new VillagerProfession(Text.literal("Nuggeter"),
|
||||
holder -> holder.value() == NUGGETER_POI.get(),
|
||||
poiTypeHolder -> poiTypeHolder.value() == NUGGETER_POI.get(),
|
||||
ImmutableSet.of(), ImmutableSet.of(),
|
||||
SoundEvents.ENTITY_VILLAGER_WORK_LIBRARIAN));
|
||||
|
||||
private static RegistryKey<PointOfInterestType> registerPoiKey(String name) {
|
||||
return RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE, Identifier.of(NuggetMod.MOD_ID, name));
|
||||
}
|
||||
|
||||
public static void registerVillagers() {
|
||||
public static void registerVillagers(IEventBus eventBus) {
|
||||
POI_TYPES.register(eventBus);
|
||||
VILLAGER_PROFESSIONS.register(eventBus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@ version = "${version}"
|
||||
displayName = "Nugget Mod"
|
||||
authors = "sillyangel"
|
||||
description = '''
|
||||
This is an example description! Tell everyone what your mod is about!
|
||||
A Minecraft mod that brings the meme of Gegagedigedagedago Nugget into the Minecraft.
|
||||
'''
|
||||
#logoFile = ""
|
||||
logoFile = "icon.png"
|
||||
modUrl="https://modrinth.com/mod/nuggetmod"
|
||||
displayURL="https://modrinth.com/mod/nuggetmod"
|
||||
|
||||
[[dependencies.nuggetmod]]
|
||||
modId = "neoforge"
|
||||
|
||||
Reference in New Issue
Block a user