diff --git a/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java b/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java index 23da57939c..fa313aa08d 100644 --- a/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java +++ b/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java @@ -17,7 +17,7 @@ public class QButtonHandler { @PlayEvent - public static void onGuiInit(ZScreenInit.Pre event) { + public static void onGuiInit(ZScreenInit.Post event) { Screen gui = event.getScreen(); if(GeneralConfig.enableQButton && (gui instanceof TitleScreen || gui instanceof PauseScreen)) { diff --git a/src/main/java/vazkii/quark/base/handler/ToolInteractionHandler.java b/src/main/java/vazkii/quark/base/handler/ToolInteractionHandler.java index 7bb5261397..2dd9dd8e66 100644 --- a/src/main/java/vazkii/quark/base/handler/ToolInteractionHandler.java +++ b/src/main/java/vazkii/quark/base/handler/ToolInteractionHandler.java @@ -22,6 +22,8 @@ import org.apache.commons.lang3.tuple.Pair; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.mod.WaxModifier; +import vazkii.zeta.event.ZRightClickBlock; +import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.bus.LoadEvent; @@ -82,8 +84,8 @@ public static void toolActionEvent(BlockEvent.BlockToolModificationEvent event) } } - @SubscribeEvent - public static void itemUse(PlayerInteractEvent.RightClickBlock event) { + @PlayEvent + public static void itemUse(ZRightClickBlock event) { ItemStack stack = event.getItemStack(); if(stack.getItem() == Items.HONEYCOMB) { diff --git a/src/main/java/vazkii/quark/base/network/message/EditSignMessage.java b/src/main/java/vazkii/quark/base/network/message/EditSignMessage.java index f1b34c5f9f..249bba9b20 100644 --- a/src/main/java/vazkii/quark/base/network/message/EditSignMessage.java +++ b/src/main/java/vazkii/quark/base/network/message/EditSignMessage.java @@ -23,7 +23,7 @@ public EditSignMessage(BlockPos pos) { @Override public boolean receive(IZetaNetworkEventContext context) { - context.enqueueWork(() -> SignEditingModule.openSignGuiClient(pos)); + context.enqueueWork(() -> SignEditingModule.Client.openSignGuiClient(pos)); return true; } diff --git a/src/main/java/vazkii/quark/base/proxy/CommonProxy.java b/src/main/java/vazkii/quark/base/proxy/CommonProxy.java index b8b65a4ee5..63db203093 100644 --- a/src/main/java/vazkii/quark/base/proxy/CommonProxy.java +++ b/src/main/java/vazkii/quark/base/proxy/CommonProxy.java @@ -57,7 +57,8 @@ public void start() { Quark.ZETA.playBus .subscribe(SyncedFlagHandler.class) .subscribe(ContributorRewardHandler.class) - .subscribe(FuelHandler.class); + .subscribe(FuelHandler.class) + .subscribe(ToolInteractionHandler.class); MinecraftForge.EVENT_BUS.register(CapabilityHandler.class); MinecraftForge.EVENT_BUS.register(ToolInteractionHandler.class); diff --git a/src/main/java/vazkii/quark/content/tweaks/client/emote/CustomEmoteDescriptor.java b/src/main/java/vazkii/quark/content/tweaks/client/emote/CustomEmoteDescriptor.java index c9a042e8e3..22c5946af3 100644 --- a/src/main/java/vazkii/quark/content/tweaks/client/emote/CustomEmoteDescriptor.java +++ b/src/main/java/vazkii/quark/content/tweaks/client/emote/CustomEmoteDescriptor.java @@ -15,7 +15,7 @@ public CustomEmoteDescriptor(String name, String regName, int index) { public static ResourceLocation getSprite(String name) { ResourceLocation customRes = new ResourceLocation(EmoteHandler.CUSTOM_EMOTE_NAMESPACE, name); - if(EmotesModule.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes)) + if(EmotesModule.Client.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes)) return customRes; return new ResourceLocation("quark", "textures/emote/custom.png"); diff --git a/src/main/java/vazkii/quark/content/tweaks/client/emote/EmoteHandler.java b/src/main/java/vazkii/quark/content/tweaks/client/emote/EmoteHandler.java index f51413cbf8..473c8a9b11 100644 --- a/src/main/java/vazkii/quark/content/tweaks/client/emote/EmoteHandler.java +++ b/src/main/java/vazkii/quark/content/tweaks/client/emote/EmoteHandler.java @@ -26,15 +26,12 @@ import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -@OnlyIn(Dist.CLIENT) public final class EmoteHandler { public static final String CUSTOM_EMOTE_NAMESPACE = "quark_custom"; @@ -64,14 +61,12 @@ public static void addCustomEmote(String name) { emoteMap.put(reg, desc); } - @OnlyIn(Dist.CLIENT) public static void putEmote(Entity player, String emoteName, int tier) { if(player instanceof AbstractClientPlayer clientPlayer && emoteMap.containsKey(emoteName)) { putEmote(clientPlayer, emoteMap.get(emoteName), tier); } } - @OnlyIn(Dist.CLIENT) private static void putEmote(AbstractClientPlayer player, EmoteDescriptor desc, int tier) { String name = player.getGameProfile().getName(); if(desc == null) diff --git a/src/main/java/vazkii/quark/content/tweaks/module/ArmedArmorStandsModule.java b/src/main/java/vazkii/quark/content/tweaks/module/ArmedArmorStandsModule.java index bf46ace416..6b14f20298 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/ArmedArmorStandsModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/ArmedArmorStandsModule.java @@ -3,9 +3,9 @@ import net.minecraft.world.entity.decoration.ArmorStand; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -import net.minecraftforge.event.entity.EntityEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZEntityConstruct; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.util.Hint; @@ -13,13 +13,13 @@ * @author WireSegal * Created at 8:40 AM on 8/27/19. */ -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class ArmedArmorStandsModule extends ZetaModule { @Hint Item armor_stand = Items.ARMOR_STAND; - @SubscribeEvent - public void entityConstruct(EntityEvent.EntityConstructing event) { + @PlayEvent + public void entityConstruct(ZEntityConstruct event) { if(event.getEntity() instanceof ArmorStand stand) { if(!stand.isShowArms()) setShowArms(stand, true); diff --git a/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java b/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java index 00defc49e2..6e1efd0a35 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java @@ -17,14 +17,12 @@ import net.minecraft.world.inventory.RecipeBookType; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.level.GameRules; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.ScreenEvent.Init; -import net.minecraftforge.event.TickEvent.ClientTickEvent; -import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.client.event.ZEndClientTick; +import vazkii.zeta.client.event.ZScreenInit; +import vazkii.zeta.event.ZPlayerLoggedIn; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.ZConfigChanged; @@ -32,7 +30,7 @@ import java.util.*; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class AutomaticRecipeUnlockModule extends ZetaModule { @Config(description = "A list of recipe names that should NOT be added in by default") @@ -51,8 +49,8 @@ public final void configChanged(ZConfigChanged event) { staticEnabled = enabled; } - @SubscribeEvent - public void onPlayerLoggedIn(PlayerLoggedInEvent event) { + @PlayEvent + public void onPlayerLoggedIn(ZPlayerLoggedIn event) { Player player = event.getEntity(); if(player instanceof ServerPlayer spe) { @@ -86,40 +84,6 @@ public void onPlayerLoggedIn(PlayerLoggedInEvent event) { } } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onInitGui(Init.Post event) { - Screen gui = event.getScreen(); - if(disableRecipeBook && gui instanceof RecipeUpdateListener) { - Minecraft.getInstance().player.getRecipeBook().getBookSettings().setOpen(RecipeBookType.CRAFTING, false); - - List widgets = event.getListenersList(); - for(GuiEventListener w : widgets) - if(w instanceof ImageButton) { - event.removeListener(w); - return; - } - } - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void clientTick(ClientTickEvent event) { - Minecraft mc = Minecraft.getInstance(); - if(mc.player != null && mc.player.tickCount < 20) { - ToastComponent toasts = mc.getToasts(); - Queue toastQueue = toasts.queued; - for(Toast toast : toastQueue) - if(toast instanceof RecipeToast recipeToast) { - List> stacks = recipeToast.recipes; - if(stacks.size() > 100) { - toastQueue.remove(toast); - return; - } - } - } - } - public static void removeRecipeAdvancements(Map builders) { if (!staticEnabled || !filterRecipeAdvancements) return; @@ -134,4 +98,41 @@ public static void removeRecipeAdvancements(Map widgets = event.getListenersList(); + for(GuiEventListener w : widgets) + if(w instanceof ImageButton) { + event.removeListener(w); + return; + } + } + } + + @PlayEvent + public void clientTick(ZEndClientTick event) { + Minecraft mc = Minecraft.getInstance(); + if(mc.player != null && mc.player.tickCount < 20) { + ToastComponent toasts = mc.getToasts(); + Queue toastQueue = toasts.queued; + for(Toast toast : toastQueue) + if(toast instanceof RecipeToast recipeToast) { + List> stacks = recipeToast.recipes; + if(stacks.size() > 100) { + toastQueue.remove(toast); + return; + } + } + } + } + + } } diff --git a/src/main/java/vazkii/quark/content/tweaks/module/BetterElytraRocketModule.java b/src/main/java/vazkii/quark/content/tweaks/module/BetterElytraRocketModule.java index a6948be75b..9594ba80d4 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/BetterElytraRocketModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/BetterElytraRocketModule.java @@ -7,16 +7,16 @@ import net.minecraft.world.item.FireworkRocketItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZRightClickItem; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class BetterElytraRocketModule extends ZetaModule { - @SubscribeEvent - public void onUseRocket(PlayerInteractEvent.RightClickItem event) { + @PlayEvent + public void onUseRocket(ZRightClickItem event) { Player player = event.getEntity(); if(!player.isFallFlying() && player.getItemBySlot(EquipmentSlot.CHEST).canElytraFly(player)) { Level world = player.level; diff --git a/src/main/java/vazkii/quark/content/tweaks/module/CampfiresBoostElytraModule.java b/src/main/java/vazkii/quark/content/tweaks/module/CampfiresBoostElytraModule.java index 9c48572375..fe88e735e1 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/CampfiresBoostElytraModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/CampfiresBoostElytraModule.java @@ -11,14 +11,14 @@ import net.minecraft.world.level.block.CampfireBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.event.TickEvent.PlayerTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZPlayerTick; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.util.Hint; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class CampfiresBoostElytraModule extends ZetaModule { @Config public double boostStrength = 0.5; @@ -27,9 +27,9 @@ public class CampfiresBoostElytraModule extends ZetaModule { @Hint Item campfire = Items.CAMPFIRE; @Hint Item soul_campfire = Items.SOUL_CAMPFIRE; - @SubscribeEvent - public void onPlayerTick(PlayerTickEvent event) { - Player player = event.player; + @PlayEvent + public void onPlayerTick(ZPlayerTick.Start event) { + Player player = event.getPlayer(); if(player.isFallFlying()) { Vec3 motion = player.getDeltaMovement(); diff --git a/src/main/java/vazkii/quark/content/tweaks/module/CompassesWorkEverywhereModule.java b/src/main/java/vazkii/quark/content/tweaks/module/CompassesWorkEverywhereModule.java index e76ebb0598..30eed58129 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/CompassesWorkEverywhereModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/CompassesWorkEverywhereModule.java @@ -8,12 +8,8 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.event.TickEvent.PlayerTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZPlayerTick; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.util.Hint; @@ -24,7 +20,7 @@ import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.client.event.ZClientSetup; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class CompassesWorkEverywhereModule extends ZetaModule { @Config public static boolean enableCompassNerf = true; @@ -36,17 +32,6 @@ public class CompassesWorkEverywhereModule extends ZetaModule { @Hint("clock_nerf") Item clock = Items.CLOCK; - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void clientSetup(ZClientSetup e) { - // register = addPropertyOverride - if(enabled && (enableCompassNerf || enableNether || enableEnd)) - e.enqueueWork(() -> ItemProperties.register(Items.COMPASS, new ResourceLocation("angle"), new CompassAngleGetter.Impl())); - - if(enabled && enableClockNerf) - e.enqueueWork(() -> ItemProperties.register(Items.CLOCK, new ResourceLocation("time"), new ClockTimeGetter.Impl())); - } - @PlayEvent public void addAdditionalHints(ZGatherHints consumer) { if(!enableNether && !enableEnd && !enableCompassNerf) @@ -68,18 +53,35 @@ public void addAdditionalHints(ZGatherHints consumer) { consumer.accept(Items.COMPASS, comp); } - @SubscribeEvent - public void onUpdate(PlayerTickEvent event) { - if(event.phase == Phase.START) { - Inventory inventory = event.player.getInventory(); - for(int i = 0; i < inventory.getContainerSize(); i++) { - ItemStack stack = inventory.getItem(i); - if(stack.getItem() == Items.COMPASS) - CompassAngleGetter.tickCompass(event.player, stack); - else if(stack.getItem() == Items.CLOCK) - ClockTimeGetter.tickClock(stack); - } + @PlayEvent + public void onUpdate(ZPlayerTick.Start event) { + Inventory inventory = event.getPlayer().getInventory(); + for(int i = 0; i < inventory.getContainerSize(); i++) { + ItemStack stack = inventory.getItem(i); + if(stack.getItem() == Items.COMPASS) + CompassAngleGetter.tickCompass(event.getPlayer(), stack); + else if(stack.getItem() == Items.CLOCK) + ClockTimeGetter.tickClock(stack); } } + @ZetaLoadModule(clientReplacement = true) + public static class Client extends CompassesWorkEverywhereModule { + + @LoadEvent + public void clientSetup(ZClientSetup e) { + e.enqueueWork(() -> { + if(!enabled) + return; + + if(enableCompassNerf || enableNether || enableEnd) + ItemProperties.register(Items.COMPASS, new ResourceLocation("angle"), new CompassAngleGetter.Impl()); + + if(enableClockNerf) + ItemProperties.register(Items.CLOCK, new ResourceLocation("time"), new ClockTimeGetter.Impl()); + }); + } + + } + } diff --git a/src/main/java/vazkii/quark/content/tweaks/module/DiamondRepairModule.java b/src/main/java/vazkii/quark/content/tweaks/module/DiamondRepairModule.java index 591b484005..2eb94f4233 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/DiamondRepairModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/DiamondRepairModule.java @@ -8,7 +8,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.ZConfigChanged; @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.List; -@LoadModule(category = "tweaks") +@ZetaLoadModule(category = "tweaks") public class DiamondRepairModule extends ZetaModule { @Config(name = "Repair Item Changes", diff --git a/src/main/java/vazkii/quark/content/tweaks/module/DragonScalesModule.java b/src/main/java/vazkii/quark/content/tweaks/module/DragonScalesModule.java index 33ece134cd..eafaabb246 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/DragonScalesModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/DragonScalesModule.java @@ -7,17 +7,17 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.item.QuarkItem; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZLivingTick; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.util.Hint; import vazkii.quark.content.tweaks.recipe.ElytraDuplicationRecipe; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class DragonScalesModule extends ZetaModule { @Hint public static Item dragon_scale; @@ -29,8 +29,8 @@ public final void register(ZRegister event) { dragon_scale = new QuarkItem("dragon_scale", this, new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)); } - @SubscribeEvent - public void onEntityTick(LivingTickEvent event) { + @PlayEvent + public void onEntityTick(ZLivingTick event) { if(event.getEntity() instanceof EnderDragon dragon && !event.getEntity().getCommandSenderWorld().isClientSide) { if(dragon.getDragonFight() != null && dragon.getDragonFight().hasPreviouslyKilledDragon() && dragon.dragonDeathTime == 100) { Vec3 pos = dragon.position(); diff --git a/src/main/java/vazkii/quark/content/tweaks/module/DyeableItemFramesModule.java b/src/main/java/vazkii/quark/content/tweaks/module/DyeableItemFramesModule.java index 08d65391cd..1b85ac9523 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/DyeableItemFramesModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/DyeableItemFramesModule.java @@ -23,12 +23,10 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.event.ZRightClickBlock; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.zeta.util.Hint; import vazkii.quark.content.tweaks.client.render.entity.DyedItemFrameRenderer; @@ -38,7 +36,7 @@ import vazkii.zeta.client.event.ZAddModels; import vazkii.zeta.client.event.ZClientSetup; -@LoadModule(category = "tweaks", hasSubscriptions = true) +@ZetaLoadModule(category = "tweaks") public class DyeableItemFramesModule extends ZetaModule { public static EntityType entityType; @@ -61,20 +59,8 @@ public final void register(ZRegister event) { Quark.ZETA.dyeables.register(Items.GLOW_ITEM_FRAME, this); } - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerAdditionalModels(ZAddModels event) { - event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/dyed_item_frame", "inventory")); - event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/dyed_item_frame_map", "inventory")); - } - - @LoadEvent - public final void clientSetup(ZClientSetup event) { - EntityRenderers.register(entityType, DyedItemFrameRenderer::new); - } - - @SubscribeEvent - public void onUse(PlayerInteractEvent.RightClickBlock event) { + @PlayEvent + public void onUse(ZRightClickBlock event) { Player player = event.getEntity(); InteractionHand hand = event.getHand(); ItemStack stack = player.getItemInHand(hand); @@ -136,4 +122,20 @@ protected boolean mayPlace(Player player, Direction direction, ItemStack stack, return !player.level.isOutsideBuildHeight(pos) && player.mayUseItemAt(pos, direction, stack); } + @ZetaLoadModule(clientReplacement = true) + public static class Client extends DyeableItemFramesModule { + + @LoadEvent + public void registerAdditionalModels(ZAddModels event) { + event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/dyed_item_frame", "inventory")); + event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/dyed_item_frame_map", "inventory")); + } + + @LoadEvent + public final void clientSetup(ZClientSetup event) { + EntityRenderers.register(entityType, DyedItemFrameRenderer::new); + } + + } + } diff --git a/src/main/java/vazkii/quark/content/tweaks/module/EmotesModule.java b/src/main/java/vazkii/quark/content/tweaks/module/EmotesModule.java index 3dee42e32e..a145c5ff6c 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/EmotesModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/EmotesModule.java @@ -30,22 +30,18 @@ import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.RepositorySource; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; -import net.minecraftforge.client.event.RenderLivingEvent; -import net.minecraftforge.client.event.ScreenEvent; -import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay; -import net.minecraftforge.event.TickEvent.RenderTickEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.aurelienribon.tweenengine.Tween; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.handler.ContributorRewardHandler; -import vazkii.quark.base.module.LoadModule; +import vazkii.zeta.client.event.ZRenderLiving; +import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderTick; +import vazkii.zeta.client.event.ZScreenInit; import vazkii.zeta.event.ZConfigChanged; +import vazkii.zeta.event.ZInputEvent; import vazkii.zeta.event.ZModulesReady; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.network.QuarkNetwork; @@ -61,7 +57,7 @@ import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.client.event.ZKeyMapping; -@LoadModule(category = "tweaks", hasSubscriptions = true, subscribeOn = Dist.CLIENT) +@ZetaLoadModule(category = "tweaks") public class EmotesModule extends ZetaModule { private static final Set DEFAULT_EMOTE_NAMES = ImmutableSet.of( @@ -97,145 +93,143 @@ public class EmotesModule extends ZetaModule { @Config(description = "Enable this to make custom emotes read the file every time they're triggered so you can edit on the fly.\nDO NOT ship enabled this in a modpack, please.") public static boolean customEmoteDebug = false; - + @Config public static int buttonShiftX = 0; @Config public static int buttonShiftY = 0; public static boolean emotesVisible = false; public static File emotesDir; - @OnlyIn(Dist.CLIENT) - public static CustomEmoteIconResourcePack resourcePack; - - @OnlyIn(Dist.CLIENT) - private static Map emoteKeybinds; + @ZetaLoadModule(clientReplacement = true) + public static class Client extends EmotesModule { - @LoadEvent - public void onReady(ZModulesReady e) { - Minecraft mc = Minecraft.getInstance(); - if (mc == null) - return; // Mojang datagen has no client instance available + public static CustomEmoteIconResourcePack resourcePack; - emotesDir = new File(mc.gameDirectory, "/config/quark_emotes"); - if(!emotesDir.exists()) - emotesDir.mkdirs(); + private static Map emoteKeybinds; - mc.getResourcePackRepository().addPackFinder(new RepositorySource() { + @LoadEvent + public void onReady(ZModulesReady e) { + Minecraft mc = Minecraft.getInstance(); + if (mc == null) + return; // Mojang datagen has no client instance available - @Override - public void loadPacks(@Nonnull Consumer packConsumer, @Nonnull Pack.PackConstructor packInfoFactory) { - resourcePack = new CustomEmoteIconResourcePack(); + emotesDir = new File(mc.gameDirectory, "/config/quark_emotes"); + if(!emotesDir.exists()) + emotesDir.mkdirs(); - String name = "quark:emote_resources"; - Pack t = Pack.create(name, true, () -> resourcePack, packInfoFactory, Pack.Position.TOP, tx->tx); - packConsumer.accept(t); - } - }); - } + mc.getResourcePackRepository().addPackFinder(new RepositorySource() { - @LoadEvent - public final void clientSetup(ZClientSetup event) { - Tween.registerAccessor(HumanoidModel.class, ModelAccessor.INSTANCE); - } + @Override + public void loadPacks(@Nonnull Consumer packConsumer, @Nonnull Pack.PackConstructor packInfoFactory) { + Client.resourcePack = new CustomEmoteIconResourcePack(); - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerKeybinds(ZKeyMapping event) { - int sortOrder = 0; + String name = "quark:emote_resources"; + Pack t = Pack.create(name, true, () -> Client.resourcePack, packInfoFactory, Pack.Position.TOP, tx->tx); + packConsumer.accept(t); + } + }); + } - emoteKeybinds = new HashMap<>(); - for (String s : DEFAULT_EMOTE_NAMES) - emoteKeybinds.put(event.init("quark.emote." + s, null, QuarkClient.EMOTE_GROUP, sortOrder++), s); - for (String s : PATREON_EMOTES) - emoteKeybinds.put(event.init("quark.keybind.patreon_emote." + s, null, QuarkClient.EMOTE_GROUP, sortOrder++), s); - } + @LoadEvent + public final void clientSetup(ZClientSetup event) { + Tween.registerAccessor(HumanoidModel.class, ModelAccessor.INSTANCE); + } - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void configChangedClient(ZConfigChanged e) { - EmoteHandler.clearEmotes(); + @LoadEvent + public void registerKeybinds(ZKeyMapping event) { + int sortOrder = 0; - for(String s : enabledEmotes) { - if (DEFAULT_EMOTE_NAMES.contains(s)) - EmoteHandler.addEmote(s); + Client.emoteKeybinds = new HashMap<>(); + for (String s : DEFAULT_EMOTE_NAMES) + Client.emoteKeybinds.put(event.init("quark.emote." + s, null, QuarkClient.EMOTE_GROUP, sortOrder++), s); + for (String s : PATREON_EMOTES) + Client.emoteKeybinds.put(event.init("quark.keybind.patreon_emote." + s, null, QuarkClient.EMOTE_GROUP, sortOrder++), s); } - for(String s : PATREON_EMOTES) - EmoteHandler.addEmote(s); + @LoadEvent + public void configChanged(ZConfigChanged e) { + EmoteHandler.clearEmotes(); - for(String s : customEmotes) - EmoteHandler.addCustomEmote(s); - } + for(String s : enabledEmotes) { + if (DEFAULT_EMOTE_NAMES.contains(s)) + EmoteHandler.addEmote(s); + } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void initGui(ScreenEvent.Init.Post event) { - Screen gui = event.getScreen(); - if(gui instanceof ChatScreen) { - Map> descriptorSorting = new TreeMap<>(); + for(String s : PATREON_EMOTES) + EmoteHandler.addEmote(s); - for (EmoteDescriptor desc : EmoteHandler.emoteMap.values()) { - if (desc.getTier() <= ContributorRewardHandler.localPatronTier) { - List descriptors = descriptorSorting.computeIfAbsent(desc.getTier(), k -> new LinkedList<>()); + for(String s : customEmotes) + EmoteHandler.addCustomEmote(s); + } - descriptors.add(desc); + @PlayEvent + public void initGui(ZScreenInit.Post event) { + Screen gui = event.getScreen(); + if(gui instanceof ChatScreen) { + Map> descriptorSorting = new TreeMap<>(); + + for (EmoteDescriptor desc : EmoteHandler.emoteMap.values()) { + if (desc.getTier() <= ContributorRewardHandler.localPatronTier) { + List descriptors = descriptorSorting.computeIfAbsent(desc.getTier(), k -> new LinkedList<>()); + + descriptors.add(desc); + } } - } - int rows = 0; - int row = 0; - int tierRow, rowPos; + int rows = 0; + int row = 0; + int tierRow, rowPos; - Minecraft mc = Minecraft.getInstance(); - boolean expandDown = mc.options.showSubtitles().get(); - - Set keys = descriptorSorting.keySet(); - for(int tier : keys) { - List descriptors = descriptorSorting.get(tier); - if (descriptors != null) { - rows += descriptors.size() / 3; - if (descriptors.size() % 3 != 0) - rows++; + Minecraft mc = Minecraft.getInstance(); + boolean expandDown = mc.options.showSubtitles().get(); + + Set keys = descriptorSorting.keySet(); + for(int tier : keys) { + List descriptors = descriptorSorting.get(tier); + if (descriptors != null) { + rows += descriptors.size() / 3; + if (descriptors.size() % 3 != 0) + rows++; + } } - } - int buttonX = buttonShiftX; - int buttonY = (expandDown ? 2 : gui.height - 40) + buttonShiftY; - - List