Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20.x' into 1.20.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Oct 31, 2024
2 parents 98d227a + cd21e22 commit 383bd7e
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/generated/resources/assets/doom_and_gloom/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"effect.doom_and_gloom.warding.description": "Wards against evil spirits",
"entity.doom_and_gloom.dirt_mound": "Dirt Mound",
"entity.doom_and_gloom.holler": "Holler",
"entity.minecraft.villager.doom_and_gloom.gravetender": "Gravetender",
"gui.doom_and_gloom.stone_tablet.cancel": "Cancel",
"gui.doom_and_gloom.stone_tablet.engrave": "Engrave",
"item.doom_and_gloom.bush_hammer": "Bush Hammer",
Expand All @@ -58,7 +59,5 @@
"subtitles.entity.holler_death": "Holler dies",
"subtitles.entity.holler_hollers": "Holler wails",
"subtitles.entity.holler_hurt": "Holler hurts",
"subtitles.entity.holler_shrieks": "Holler shrieks",
"subtitles.gui.stone_tablet.cancel": "Cancel",
"subtitles.gui.stone_tablet.engrave": "Engrave"
"subtitles.entity.holler_shrieks": "Holler shrieks"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"values": [
"doom_and_gloom:vigil_candle",
"doom_and_gloom:white_vigil_candle",
"doom_and_gloom:orange_vigil_candle",
"doom_and_gloom:magenta_vigil_candle",
"doom_and_gloom:light_blue_vigil_candle",
"doom_and_gloom:yellow_vigil_candle",
"doom_and_gloom:lime_vigil_candle",
"doom_and_gloom:pink_vigil_candle",
"doom_and_gloom:gray_vigil_candle",
"doom_and_gloom:light_gray_vigil_candle",
"doom_and_gloom:cyan_vigil_candle",
"doom_and_gloom:purple_vigil_candle",
"doom_and_gloom:blue_vigil_candle",
"doom_and_gloom:brown_vigil_candle",
"doom_and_gloom:green_vigil_candle",
"doom_and_gloom:red_vigil_candle",
"doom_and_gloom:black_vigil_candle",
"doom_and_gloom:maroon_vigil_candle",
"doom_and_gloom:rose_vigil_candle",
"doom_and_gloom:coral_vigil_candle",
"doom_and_gloom:indigo_vigil_candle",
"doom_and_gloom:navy_vigil_candle",
"doom_and_gloom:slate_vigil_candle",
"doom_and_gloom:olive_vigil_candle",
"doom_and_gloom:amber_vigil_candle",
"doom_and_gloom:beige_vigil_candle",
"doom_and_gloom:teal_vigil_candle",
"doom_and_gloom:mint_vigil_candle",
"doom_and_gloom:aqua_vigil_candle",
"doom_and_gloom:verdant_vigil_candle",
"doom_and_gloom:forest_vigil_candle",
"doom_and_gloom:ginger_vigil_candle",
"doom_and_gloom:tan_vigil_candle"
]
}
3 changes: 3 additions & 0 deletions src/main/java/galena/doom_and_gloom/data/OItemTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import galena.doom_and_gloom.DoomAndGloom;
import galena.doom_and_gloom.index.OItems;
import galena.doom_and_gloom.index.OTags;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.ItemTagsProvider;
Expand Down Expand Up @@ -30,5 +31,7 @@ protected void addTags(HolderLookup.Provider provider) {
tag(TOOLS_BUSH_HAMMER).add(OItems.BUSH_HAMMER.get());

tag(ItemTags.MUSIC_DISCS).add(OItems.MUSIC_DISC_AFTERLIFE.get());

copy(OTags.Blocks.VIGIL_CANDLES, OTags.Items.VIGIL_CANDLES);
}
}
3 changes: 3 additions & 0 deletions src/main/java/galena/doom_and_gloom/data/OLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import galena.doom_and_gloom.index.OEffects;
import galena.doom_and_gloom.index.OEntityTypes;
import galena.doom_and_gloom.index.OItems;
import galena.doom_and_gloom.index.OVillagerTypes;
import net.minecraft.data.PackOutput;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -44,6 +45,8 @@ protected void addTranslations() {
addSubtitle("entity", "holler_shrieks", "Holler shrieks");
addSubtitle("entity", "holler_hollers", "Holler wails"); //howls? howls? whispers?

add("entity.minecraft.villager." + DoomAndGloom.MOD_ID + ".gravetender", "Gravetender");

add("gui.doom_and_gloom.stone_tablet.engrave", "Engrave");
add("gui.doom_and_gloom.stone_tablet.cancel", "Cancel");

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/galena/doom_and_gloom/index/OTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static class Items {

public static final TagKey<Item> TOOLS_BUSH_HAMMER = forgeTag("tools/bush_hammer");

public static final TagKey<Item> VIGIL_CANDLES = tag("vigil_candles");

private static TagKey<Item> tag(String name) {
return ItemTags.create(DoomAndGloom.modLoc(name));
}
Expand Down
72 changes: 67 additions & 5 deletions src/main/java/galena/doom_and_gloom/index/OVillagerTrades.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package galena.doom_and_gloom.index;

import galena.doom_and_gloom.DoomAndGloom;
import net.mehvahdjukaar.moonlight.api.trades.SimpleItemListing;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.npc.VillagerTrades.EmeraldForItems;
import net.minecraft.world.entity.npc.VillagerTrades.EnchantedItemForEmeralds;
import net.minecraft.world.entity.npc.VillagerTrades.ItemsForEmeralds;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.trading.MerchantOffer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.BasicItemListing;
import net.minecraftforge.event.village.VillagerTradesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand All @@ -20,15 +31,66 @@ public class OVillagerTrades {


@SubscribeEvent
public static void tadeEvent(VillagerTradesEvent event){
public static void tadeEvent(VillagerTradesEvent event) {
VillagerProfession type = event.getType();
if (type == OVillagerTypes.GRAVETENDER.get()){
addGravetenderTrades(event);
if (type == OVillagerTypes.GRAVETENDER.get()) {
addGravetenderTrades(event);
}
}

public record TagForEmeralds(TagKey<Item> tag, int cost, int emeralds, int maxUses, int xp, float priceMultiplier) implements VillagerTrades.ItemListing {

@Override
public @Nullable MerchantOffer getOffer(Entity entity, RandomSource random) {
if(!(entity.level() instanceof ServerLevel level)) return null;
var tagHolder = level.registryAccess().registryOrThrow(Registries.ITEM).getOrCreateTag(tag);
return tagHolder.getRandomElement(random).map(item ->
new MerchantOffer(new ItemStack(Items.EMERALD, cost), new ItemStack(item), maxUses, xp, priceMultiplier)
).orElse(null);
}
}

public record EmeraldForTag(TagKey<Item> tag, int emeralds, int count, int maxUses, int xp, float priceMultiplier) implements VillagerTrades.ItemListing {

@Override
public @Nullable MerchantOffer getOffer(Entity entity, RandomSource random) {
if(!(entity.level() instanceof ServerLevel level)) return null;
var tagHolder = level.registryAccess().registryOrThrow(Registries.ITEM).getOrCreateTag(tag);
return tagHolder.getRandomElement(random).map(item ->
new MerchantOffer(new ItemStack(item), new ItemStack(Items.EMERALD, emeralds), maxUses, xp, priceMultiplier)
).orElse(null);
}
}

private static void addGravetenderTrades(VillagerTradesEvent event) {
// event.getTrades().put(1, List.of(BasicItemListing(Items.BONE)))
var trades = event.getTrades();

trades.put(1, List.of(
new ItemsForEmeralds(new ItemStack(Items.STONE_SHOVEL), 1, 1, 12, 1, 0.2F),
new ItemsForEmeralds(Items.ROSE_BUSH, 1, 1, 8, 2),
new BasicItemListing(new ItemStack(Items.POPPY, 8), new ItemStack(Items.EMERALD), 1, 12, 0.2F),
new BasicItemListing(new ItemStack(Items.CORNFLOWER, 8), new ItemStack(Items.EMERALD), 1, 12, 0.2F)
));

trades.put(2, List.of(
new ItemsForEmeralds(Items.GOLD_NUGGET, 1, 5, 8, 5),
new TagForEmeralds(OTags.Items.VIGIL_CANDLES, 2, 1, 12, 10, 2F),
new ItemsForEmeralds(Items.FLOWER_POT, 2, 1, 12, 5)
));

trades.put(3, List.of(
new EnchantedItemForEmeralds(Items.IRON_SHOVEL, 2, 3, 10, 0.2F),
new EmeraldForTag(ItemTags.CANDLES, 2, 6, 12, 2, 0.1F)
));

trades.put(4, List.of(
new EmeraldForItems(Items.LANTERN, 2, 8, 15),
new ItemsForEmeralds(new ItemStack(Items.WITHER_ROSE), 10, 2, 8, 20, 2F)
));

trades.put(5, List.of(
new EnchantedItemForEmeralds(Items.DIAMOND_SHOVEL, 13, 3, 30, 0.2F)
));
}

}
4 changes: 3 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
public net.minecraft.server.network.ServerGamePacketListenerImpl m_243132_(Ljava/lang/String;)Ljava/util/concurrent/CompletableFuture; # filterTextPacket
public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210560_ # templates
public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool f_210559_ # rawTemplates

public net.minecraft.world.entity.npc.VillagerTrades$EnchantedItemForEmeralds
public net.minecraft.world.entity.npc.VillagerTrades$ItemsForEmeralds
public net.minecraft.world.entity.npc.VillagerTrades$EmeraldForItems
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TODO

[[dependencies.doom_and_gloom]]
modId="oreganized"
mandatory=true
mandatory=false
versionRange="*"
ordering="AFTER"
side="BOTH"

0 comments on commit 383bd7e

Please sign in to comment.