Add the Engineer villager back

This commit is contained in:
Mrbysco 2024-03-11 20:48:18 +01:00
parent 4cc4b40c4b
commit 2a2f5c6cdc
16 changed files with 205 additions and 58 deletions

View file

@ -1,2 +1,2 @@
// 1.20.4 2024-03-04T22:51:31.6174299 Sound Definitions // 1.20.4 2024-03-11T20:19:22.9008098 Sound Definitions
5492914eb97f792a830608d663aaf3148987ed3e assets/actuallyadditions/sounds.json e7a33758b55803bd59c68b8024cb8484dd4f060f assets/actuallyadditions/sounds.json

View file

@ -0,0 +1,2 @@
// 1.20.4 2024-03-11T20:41:48.609238 Tags for minecraft:point_of_interest_type mod id actuallyadditions
65352c4eaf105efa72687c568c2d5b5f5fd11996 data/minecraft/tags/point_of_interest_type/acquirable_job_site.json

View file

@ -18,5 +18,10 @@
"sounds": [ "sounds": [
"actuallyadditions:reconstructor" "actuallyadditions:reconstructor"
] ]
},
"villager.work_engineer": {
"sounds": [
"actuallyadditions:coffee_machine"
]
} }
} }

View file

@ -0,0 +1,5 @@
{
"values": [
"actuallyadditions:engineer"
]
}

View file

@ -46,6 +46,7 @@ public class ActuallyAdditionsData {
generator.addProvider(true, new ItemRecipeGenerator(packOutput)); generator.addProvider(true, new ItemRecipeGenerator(packOutput));
generator.addProvider(true, generatorBlockTags); generator.addProvider(true, generatorBlockTags);
generator.addProvider(true, new ItemTagsGenerator(packOutput, lookupProvider, generatorBlockTags, helper)); generator.addProvider(true, new ItemTagsGenerator(packOutput, lookupProvider, generatorBlockTags, helper));
generator.addProvider(true, new PoiTypeTagsGenerator(packOutput, lookupProvider, helper));
generator.addProvider(true, new DamageTypeTagsGenerator(packOutput, lookupProvider, helper)); generator.addProvider(true, new DamageTypeTagsGenerator(packOutput, lookupProvider, helper));
generator.addProvider(true, new BlockStateGenerator(packOutput, helper)); generator.addProvider(true, new BlockStateGenerator(packOutput, helper));

View file

@ -0,0 +1,26 @@
package de.ellpeck.actuallyadditions.data;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.gen.village.ActuallyPOITypes;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.PoiTypeTagsProvider;
import net.minecraft.tags.PoiTypeTags;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class PoiTypeTagsGenerator extends PoiTypeTagsProvider {
public PoiTypeTagsGenerator(PackOutput output, CompletableFuture<HolderLookup.Provider> completableFuture, @Nullable ExistingFileHelper fileHelper) {
super(output, completableFuture, ActuallyAdditions.MODID, fileHelper);
}
@Override
protected void addTags(HolderLookup.Provider pProvider) {
this.tag(PoiTypeTags.ACQUIRABLE_JOB_SITE)
.add(
ActuallyPOITypes.ENGINEER.getKey()
);
}
}

View file

@ -19,5 +19,6 @@ public class SoundsGenerator extends SoundDefinitionsProvider {
add(AASounds.CRUSHER, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "crusher")))); add(AASounds.CRUSHER, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "crusher"))));
add(AASounds.COFFEE_MACHINE, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine")))); add(AASounds.COFFEE_MACHINE, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine"))));
add(AASounds.DUH_DUH_DUH_DUUUH, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh")))); add(AASounds.DUH_DUH_DUH_DUUUH, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh"))));
add(AASounds.VILLAGER_WORK_ENGINEER, definition().with(sound(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine"))));
} }
} }

View file

@ -14,6 +14,7 @@ public class AASounds {
public static DeferredHolder<SoundEvent, SoundEvent> CRUSHER = SOUNDS.register("crusher", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "crusher"))); public static DeferredHolder<SoundEvent, SoundEvent> CRUSHER = SOUNDS.register("crusher", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "crusher")));
public static DeferredHolder<SoundEvent, SoundEvent> COFFEE_MACHINE = SOUNDS.register("coffee_machine", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine"))); public static DeferredHolder<SoundEvent, SoundEvent> COFFEE_MACHINE = SOUNDS.register("coffee_machine", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "coffee_machine")));
public static DeferredHolder<SoundEvent, SoundEvent> DUH_DUH_DUH_DUUUH = SOUNDS.register("duh_duh_duh_duuuh", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh"))); public static DeferredHolder<SoundEvent, SoundEvent> DUH_DUH_DUH_DUUUH = SOUNDS.register("duh_duh_duh_duuuh", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "duh_duh_duh_duuuh")));
public static DeferredHolder<SoundEvent, SoundEvent> VILLAGER_WORK_ENGINEER = SOUNDS.register("villager.work_engineer", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ActuallyAdditions.MODID, "villager.work_engineer")));
public static void init(IEventBus bus) { public static void init(IEventBus bus) {

View file

@ -28,6 +28,9 @@ import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.gen.ActuallyVillages; import de.ellpeck.actuallyadditions.mod.gen.ActuallyVillages;
import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier; import de.ellpeck.actuallyadditions.mod.gen.modifier.BoolConfigFeatureBiomeModifier;
import de.ellpeck.actuallyadditions.mod.gen.village.ActuallyPOITypes;
import de.ellpeck.actuallyadditions.mod.gen.village.ActuallyVillagers;
import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers; import de.ellpeck.actuallyadditions.mod.inventory.ActuallyContainers;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
@ -110,6 +113,8 @@ public class ActuallyAdditions {
ActuallyTabs.init(eventBus); ActuallyTabs.init(eventBus);
ActuallyRecipes.init(eventBus); ActuallyRecipes.init(eventBus);
AASounds.init(eventBus); AASounds.init(eventBus);
ActuallyVillagers.init(eventBus);
ActuallyPOITypes.init(eventBus);
ActuallyAttachments.init(eventBus); ActuallyAttachments.init(eventBus);
ActuallyContainers.CONTAINERS.register(eventBus); ActuallyContainers.CONTAINERS.register(eventBus);
ENTITIES.register(eventBus); ENTITIES.register(eventBus);
@ -121,6 +126,7 @@ public class ActuallyAdditions {
NeoForge.EVENT_BUS.addListener(this::serverStarted); NeoForge.EVENT_BUS.addListener(this::serverStarted);
NeoForge.EVENT_BUS.addListener(this::serverStopped); NeoForge.EVENT_BUS.addListener(this::serverStopped);
NeoForge.EVENT_BUS.addListener(InitVillager::setupTrades);
NeoForge.EVENT_BUS.register(new CommonEvents()); NeoForge.EVENT_BUS.register(new CommonEvents());
// NeoForge.EVENT_BUS.register(new DungeonLoot()); // NeoForge.EVENT_BUS.register(new DungeonLoot());
NeoForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent); NeoForge.EVENT_BUS.addListener(ActuallyAdditions::reloadEvent);

View file

@ -0,0 +1,25 @@
package de.ellpeck.actuallyadditions.mod.gen.village;
import com.google.common.collect.ImmutableSet;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.Set;
import java.util.function.Supplier;
public class ActuallyPOITypes {
public static final DeferredRegister<PoiType> POI_TYPES = DeferredRegister.create(BuiltInRegistries.POINT_OF_INTEREST_TYPE, ActuallyAdditions.MODID);
public static DeferredHolder<PoiType, PoiType> ENGINEER = POI_TYPES.register("engineer", () -> new PoiType(ImmutableSet.copyOf(ActuallyBlocks.COFFEE_MACHINE.get().getStateDefinition().getPossibleStates()), 1, 1));
public static void init(IEventBus bus) {
POI_TYPES.register(bus);
}
}

View file

@ -0,0 +1,20 @@
package de.ellpeck.actuallyadditions.mod.gen.village;
import com.google.common.collect.ImmutableSet;
import de.ellpeck.actuallyadditions.mod.AASounds;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.function.Supplier;
public class ActuallyVillagers {
public static final DeferredRegister<VillagerProfession> VILLAGER_PROFESSIONS = DeferredRegister.create(BuiltInRegistries.VILLAGER_PROFESSION, ActuallyAdditions.MODID);
public static final Supplier<VillagerProfession> ENGINEER = VILLAGER_PROFESSIONS.register("engineer", () -> new VillagerProfession("engineer", holder -> holder.value().equals(ActuallyPOITypes.ENGINEER.get()), holder -> holder.value().equals(ActuallyPOITypes.ENGINEER.get()), ImmutableSet.of(), ImmutableSet.of(), AASounds.VILLAGER_WORK_ENGINEER.get()));
public static void init(IEventBus bus) {
VILLAGER_PROFESSIONS.register(bus);
}
}

View file

@ -1,53 +1,86 @@
///* /*
// * This file ("BasicTradeList.java") is part of the Actually Additions mod for Minecraft. * This file ("BasicTradeList.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// * *
// * © 2015-2017 Ellpeck * © 2015-2017 Ellpeck
// */ */
//
//package de.ellpeck.actuallyadditions.mod.gen.village; package de.ellpeck.actuallyadditions.mod.gen.village;
//
//import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
// import net.minecraft.util.RandomSource;
//import net.minecraft.entity.IMerchant; import net.minecraft.util.Tuple;
//import net.minecraft.entity.passive.EntityVillager.ITradeList; import net.minecraft.world.entity.Entity;
//import net.minecraft.entity.passive.EntityVillager.PriceInfo; import net.minecraft.world.entity.npc.VillagerTrades;
//import net.minecraft.init.Items; import net.minecraft.world.item.ItemStack;
//import net.minecraft.item.ItemStack; import net.minecraft.world.item.Items;
//import net.minecraft.village.MerchantRecipe; import net.minecraft.world.item.trading.MerchantOffer;
//import net.minecraft.village.MerchantRecipeList; import org.jetbrains.annotations.Nullable;
//
//public class BasicTradeList implements ITradeList { public class BasicTradeList implements VillagerTrades.ItemListing {
//
// private final ItemStack input; private final ItemStack input;
// private final PriceInfo inputAmount; private final PriceRange inputAmount;
// private final ItemStack stack; private final ItemStack stack;
// private final PriceInfo outputAmount; private final PriceRange outputAmount;
// private int maxUses = 3;
// public BasicTradeList(ItemStack input, PriceInfo inputAmount, ItemStack stack, PriceInfo outputAmount) { private int villagerXp = 15;
// this.input = input; private float priceMultiplier = 0.05F;
// this.inputAmount = inputAmount;
// this.stack = stack; public BasicTradeList(ItemStack input, PriceRange inputAmount, ItemStack stack, PriceRange outputAmount) {
// this.outputAmount = outputAmount; this.input = input;
// } this.inputAmount = inputAmount;
// this.stack = stack;
// public BasicTradeList(PriceInfo emeraldInput, ItemStack stack, PriceInfo outputAmount) { this.outputAmount = outputAmount;
// this(new ItemStack(Items.EMERALD), emeraldInput, stack, outputAmount); }
// }
// public BasicTradeList(PriceRange emeraldInput, ItemStack stack, PriceRange outputAmount) {
// public BasicTradeList(ItemStack input, PriceInfo inputAmount, PriceInfo emeraldOutput) { this(new ItemStack(Items.EMERALD), emeraldInput, stack, outputAmount);
// this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput); }
// }
// public BasicTradeList(ItemStack input, PriceRange inputAmount, PriceRange emeraldOutput) {
// @Override this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput);
// public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { }
// ItemStack in = this.input.copy();
// in.setCount(this.inputAmount.getPrice(random)); public BasicTradeList withMaxUses(int maxUses) {
// ItemStack out = this.stack.copy(); this.maxUses = maxUses;
// out.setCount(this.outputAmount.getPrice(random)); return this;
// recipeList.add(new MerchantRecipe(in, out)); }
// }
//} public BasicTradeList withVillagerXp(int villagerXp) {
this.villagerXp = villagerXp;
return this;
}
public BasicTradeList withPriceMultiplier(float priceMultiplier) {
this.priceMultiplier = priceMultiplier;
return this;
}
@Nullable
@Override
public MerchantOffer getOffer(Entity trader, RandomSource random) {
ItemStack in = this.input.copy();
in.setCount(this.inputAmount.getPrice(random));
ItemStack out = this.stack.copy();
out.setCount(this.outputAmount.getPrice(random));
return new MerchantOffer(in, out, this.maxUses, this.villagerXp, this.priceMultiplier);
}
public static class PriceRange extends Tuple<Integer, Integer> {
public PriceRange(int min, int max) {
super(Integer.valueOf(min), Integer.valueOf(max));
if (max < min) {
ActuallyAdditions.LOGGER.warn("PriceRange({}, {}) invalid, {} smaller than {}", Integer.valueOf(min), Integer.valueOf(max), Integer.valueOf(max), Integer.valueOf(min));
}
}
public int getPrice(RandomSource rand) {
return this.getA() >= this.getB() ? this.getA() : this.getA() + rand.nextInt(this.getB() - this.getA() + 1);
}
}
}

View file

@ -10,8 +10,28 @@
package de.ellpeck.actuallyadditions.mod.gen.village; package de.ellpeck.actuallyadditions.mod.gen.village;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.event.village.VillagerTradesEvent;
import java.util.List;
// TODO: [port] ADD BACK // TODO: [port] ADD BACK
public final class InitVillager { public final class InitVillager {
public static void setupTrades(VillagerTradesEvent event) {
if (event.getType() == ActuallyVillagers.ENGINEER.get()) {
Int2ObjectMap<List<VillagerTrades.ItemListing>> trades = event.getTrades();
trades.put(1, List.of(new BasicTradeList(new BasicTradeList.PriceRange(1, 2), new ItemStack(ActuallyBlocks.BLACK_QUARTZ_ORE.get()), new BasicTradeList.PriceRange(2, 3)), new BasicTradeList(new BasicTradeList.PriceRange(1, 2), new ItemStack(ActuallyItems.BLACK_QUARTZ.get()), new BasicTradeList.PriceRange(6, 8)), new BasicTradeList(new BasicTradeList.PriceRange(1, 3), new ItemStack(ActuallyItems.LASER_WRENCH.get()), new BasicTradeList.PriceRange(1, 1))));
trades.put(2, List.of(new BasicTradeList(new ItemStack(ActuallyItems.COFFEE_BEANS.get()), new BasicTradeList.PriceRange(20, 30), new BasicTradeList.PriceRange(1, 2)), new BasicTradeList(new BasicTradeList.PriceRange(3, 5), new ItemStack(ActuallyBlocks.ITEM_INTERFACE.get()), new BasicTradeList.PriceRange(1, 1)), new BasicTradeList(new BasicTradeList.PriceRange(10, 20), new ItemStack(ActuallyBlocks.LASER_RELAY.get()), new BasicTradeList.PriceRange(1, 2))));
trades.put(3, List.of(new BasicTradeList(new ItemStack(ActuallyBlocks.TINY_TORCH.get()), new BasicTradeList.PriceRange(30, 40), new BasicTradeList.PriceRange(1, 2)), new BasicTradeList(new BasicTradeList.PriceRange(1, 2), new ItemStack(ActuallyBlocks.WOOD_CASING.get()), new BasicTradeList.PriceRange(1, 2))));
trades.put(4, List.of(new BasicTradeList(new BasicTradeList.PriceRange(3, 5), new ItemStack(ActuallyBlocks.IRON_CASING.get()), new BasicTradeList.PriceRange(1, 2)), new BasicTradeList(new ItemStack(ActuallyBlocks.EMPOWERER.get()), new BasicTradeList.PriceRange(1, 1), new BasicTradeList.PriceRange(15, 20)), new BasicTradeList(new BasicTradeList.PriceRange(30, 40), new ItemStack(ActuallyBlocks.LASER_RELAY_EXTREME.get()), new BasicTradeList.PriceRange(1, 1))));
}
}
// //
// public static VillagerProfession jamProfession; // public static VillagerProfession jamProfession;
// public static VillagerProfession engineerProfession; // public static VillagerProfession engineerProfession;

View file

@ -6,3 +6,5 @@ public net.minecraft.world.item.crafting.ShapedRecipe pattern
public net.minecraft.world.inventory.InventoryMenu TEXTURE_EMPTY_SLOTS public net.minecraft.world.inventory.InventoryMenu TEXTURE_EMPTY_SLOTS
public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates
public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates
public net.minecraft.world.entity.npc.VillagerTrades$ItemsForEmeralds
public net.minecraft.world.entity.npc.VillagerTrades$EmeraldForItems

View file

@ -26,7 +26,7 @@
"_comment": "Entities", "_comment": "Entities",
"entity.Villager.actuallyadditions.jammer": "Jam Guy", "entity.Villager.actuallyadditions.jammer": "Jam Guy",
"entity.Villager.actuallyadditions.crystallizer": "Crystallizer", "entity.Villager.actuallyadditions.crystallizer": "Crystallizer",
"entity.Villager.actuallyadditions.engineer": "Engineer", "entity.minecraft.villager.actuallyadditions.engineer": "Engineer",
"_comment": "Banners", "_comment": "Banners",
"item.banner.actuallyadditionsBook.black": "Black Actually Additions Manual Pattern", "item.banner.actuallyadditionsBook.black": "Black Actually Additions Manual Pattern",
"item.banner.actuallyadditionsBook.red": "Red Actually Additions Manual Pattern", "item.banner.actuallyadditionsBook.red": "Red Actually Additions Manual Pattern",

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB