generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a12ba98
commit cc68bcd
Showing
13 changed files
with
198 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...java/dev/sweetberry/wwizardry/mixin/Mixin_VillagerTrades_EmeraldsForVillagerTypeItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package dev.sweetberry.wwizardry.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import dev.sweetberry.wwizardry.content.datagen.DatagenInitializer; | ||
import dev.sweetberry.wwizardry.content.villager.VillagerInitializer; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.npc.VillagerDataHolder; | ||
import net.minecraft.world.entity.npc.VillagerProfession; | ||
import net.minecraft.world.entity.npc.VillagerType; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.trading.ItemCost; | ||
import net.minecraft.world.item.trading.MerchantOffer; | ||
import net.minecraft.world.level.ItemLike; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.Map; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
@Mixin(targets = {"net/minecraft/world/entity/npc/VillagerTrades$EmeraldsForVillagerTypeItem"}) | ||
public class Mixin_VillagerTrades_EmeraldsForVillagerTypeItem { | ||
@Shadow | ||
@Final | ||
private int cost; | ||
|
||
@Shadow | ||
@Final | ||
private int maxUses; | ||
|
||
@Shadow | ||
@Final | ||
private int villagerXp; | ||
|
||
@Shadow | ||
@Final | ||
private Map<VillagerType, Item> trades; | ||
|
||
@WrapOperation( | ||
method = "<init>", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/util/stream/Stream;filter(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;" | ||
) | ||
) | ||
private Stream<VillagerType> wrapFilter(Stream<VillagerType> instance, Predicate<? super VillagerType> predicate, Operation<Stream<VillagerType>> original) { | ||
return original.call(instance, (Predicate<? super VillagerType>)(it) -> it != VillagerInitializer.FUNGAL_FOREST_VILLAGER.get() && predicate.test(it)); | ||
} | ||
|
||
@Inject( | ||
method = "getOffer", | ||
at = @At("HEAD"), | ||
cancellable = true | ||
) | ||
private void addWwizardryTrades(Entity entity, RandomSource random, CallbackInfoReturnable<MerchantOffer> cir) { | ||
if (entity instanceof VillagerDataHolder villager && villager.getVariant() == VillagerInitializer.FUNGAL_FOREST_VILLAGER.get()) { | ||
if (villager.getVillagerData().getProfession() == VillagerProfession.FISHERMAN) { | ||
assert DatagenInitializer.DENIA_WOOD.BOAT_ITEM != null; | ||
cir.setReturnValue(new MerchantOffer(new ItemCost(DatagenInitializer.DENIA_WOOD.BOAT_ITEM.get(), cost), new ItemStack(Items.EMERALD), maxUses, villagerXp, 0.05F)); | ||
} | ||
|
||
// Fall back to plains | ||
ItemCost itemCost = new ItemCost(trades.get(VillagerType.PLAINS), cost); | ||
cir.setReturnValue(new MerchantOffer(itemCost, new ItemStack(Items.EMERALD), maxUses, villagerXp, 0.05F)); | ||
} | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
common/src/main/java/dev/sweetberry/wwizardry/mixin/client/Mixin_HangingSignEditScreen.java
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
common/src/main/java/dev/sweetberry/wwizardry/mixin/client/Mixin_SignEditScreen.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
neoforge/src/main/java/dev/sweetberry/wwizardry/neoforge/NeoForgeClientEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package dev.sweetberry.wwizardry.neoforge; | ||
|
||
import com.mojang.datafixers.util.Either; | ||
import dev.sweetberry.wwizardry.WanderingWizardry; | ||
import dev.sweetberry.wwizardry.client.WanderingWizardryClient; | ||
import dev.sweetberry.wwizardry.client.content.events.ClientEvents; | ||
import dev.sweetberry.wwizardry.client.content.events.ItemTooltipHandler; | ||
import dev.sweetberry.wwizardry.client.content.events.PackReloader; | ||
import net.minecraft.client.renderer.item.ItemProperties; | ||
import net.minecraft.network.chat.FormattedText; | ||
import net.minecraft.world.inventory.tooltip.TooltipComponent; | ||
import net.minecraft.world.item.TooltipFlag; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.neoforge.client.event.ClientTickEvent; | ||
import net.neoforged.neoforge.client.event.EntityRenderersEvent; | ||
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; | ||
import net.neoforged.neoforge.client.event.RenderTooltipEvent; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
|
||
public class NeoForgeClientEvents { | ||
public static void init(IEventBus modBus) { | ||
NeoForge.EVENT_BUS.register(NeoForgeClientEvents.class); | ||
|
||
ClientEvents.registerModelPredicates((item, name, callback) -> { | ||
ItemProperties.registerGeneric( | ||
WanderingWizardry.id(name), | ||
callback | ||
); | ||
}); | ||
modBus.addListener(NeoForgeClientEvents::registerEntityRenderers); | ||
modBus.addListener(NeoForgeClientEvents::registerEntityLayers); | ||
modBus.addListener(NeoForgeClientEvents::registerClientReloadListeners); | ||
WanderingWizardryClient.init(); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onTooltip(RenderTooltipEvent.GatherComponents event) { | ||
var lines = event.getTooltipElements(); | ||
|
||
ItemTooltipHandler.addTooltips( | ||
event.getItemStack(), | ||
TooltipFlag.NORMAL, | ||
(i, c) -> lines.addAll(i, | ||
c.stream().map(it -> (FormattedText) it).map(Either::<FormattedText, TooltipComponent>left).toList() | ||
) | ||
); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onClientTick(ClientTickEvent.Post ev) { | ||
WanderingWizardryClient.tickCounter++; | ||
} | ||
|
||
public static void registerClientReloadListeners(RegisterClientReloadListenersEvent ev) { | ||
ev.registerReloadListener(new PackReloader()); | ||
} | ||
|
||
public static void registerEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { | ||
ClientEvents.registerBlockEntityRenderers((type, renderer) -> { | ||
event.registerBlockEntityRenderer(type.get(), renderer); | ||
}); | ||
|
||
ClientEvents.registerEntityRenderers((type, renderer) -> { | ||
event.registerEntityRenderer(type.get(), renderer); | ||
}); | ||
} | ||
|
||
public static void registerEntityLayers(EntityRenderersEvent.RegisterLayerDefinitions event) { | ||
ClientEvents.registerModelLayers(event::registerLayerDefinition); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.