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 fa313aa08d..2a0231d5c4 100644 --- a/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java +++ b/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java @@ -1,7 +1,5 @@ package vazkii.quark.base.client.config; -import java.util.List; - import com.google.common.collect.ImmutableSet; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; @@ -11,13 +9,15 @@ import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.client.resources.language.I18n; import vazkii.quark.base.handler.GeneralConfig; -import vazkii.zeta.client.event.ZScreenInit; +import vazkii.zeta.client.event.ZScreen; import vazkii.zeta.event.bus.PlayEvent; +import java.util.List; + public class QButtonHandler { @PlayEvent - public static void onGuiInit(ZScreenInit.Post event) { + public static void onGuiInit(ZScreen.Init.Post event) { Screen gui = event.getScreen(); if(GeneralConfig.enableQButton && (gui instanceof TitleScreen || gui instanceof PauseScreen)) { diff --git a/src/main/java/vazkii/quark/base/client/handler/InventoryButtonHandler.java b/src/main/java/vazkii/quark/base/client/handler/InventoryButtonHandler.java index 6470540421..e5a070b307 100644 --- a/src/main/java/vazkii/quark/base/client/handler/InventoryButtonHandler.java +++ b/src/main/java/vazkii/quark/base/client/handler/InventoryButtonHandler.java @@ -1,20 +1,8 @@ package vazkii.quark.base.client.handler; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Set; -import java.util.TreeSet; -import java.util.function.Consumer; -import java.util.function.Predicate; - -import javax.annotation.Nonnull; - import com.google.common.base.Supplier; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; - import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -33,12 +21,15 @@ import vazkii.quark.base.QuarkClient; import vazkii.quark.base.handler.GeneralConfig; import vazkii.quark.base.handler.InventoryTransferHandler; -import vazkii.zeta.client.event.ZScreenInit; -import vazkii.zeta.client.event.ZScreenKeyPressed; -import vazkii.zeta.client.event.ZScreenMousePressed; +import vazkii.zeta.client.event.ZKeyMapping; +import vazkii.zeta.client.event.ZScreen; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.client.event.ZKeyMapping; + +import javax.annotation.Nonnull; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Predicate; public final class InventoryButtonHandler { @@ -46,7 +37,7 @@ public final class InventoryButtonHandler { private static final Multimap currentButtons = Multimaps.newSetMultimap(new HashMap<>(), LinkedHashSet::new); @PlayEvent - public static void initGui(ZScreenInit.Post event) { + public static void initGui(ZScreen.Init.Post event) { Minecraft mc = Minecraft.getInstance(); Screen screen = event.getScreen(); if(GeneralConfig.printScreenClassnames) { @@ -91,7 +82,7 @@ private static Collection forGui(Screen gui) { } @PlayEvent - public static void mouseInputEvent(ZScreenMousePressed.Pre pressed) { + public static void mouseInputEvent(ZScreen.MouseButtonPressed.Pre pressed) { Screen gui = pressed.getScreen(); if (gui instanceof AbstractContainerScreen screen) { if(!GeneralConfig.isScreenAllowed(screen)) @@ -111,7 +102,7 @@ public static void mouseInputEvent(ZScreenMousePressed.Pre pressed) { } @PlayEvent - public static void keyboardInputEvent(ZScreenKeyPressed.Pre pressed) { + public static void keyboardInputEvent(ZScreen.KeyPressed.Pre pressed) { Screen gui = pressed.getScreen(); if (gui instanceof AbstractContainerScreen screen) { if(!GeneralConfig.isScreenAllowed(screen)) @@ -131,7 +122,7 @@ public static void keyboardInputEvent(ZScreenKeyPressed.Pre pressed) { } - private static void applyProviders(ZScreenInit.Post event, ButtonTargetType type, AbstractContainerScreen screen, Predicate slotPred) { + private static void applyProviders(ZScreen.Init.Post event, ButtonTargetType type, AbstractContainerScreen screen, Predicate slotPred) { Collection holders = providers.get(type); if(!holders.isEmpty()) { for(Slot slot : screen.getMenu().slots) diff --git a/src/main/java/vazkii/quark/base/handler/MiscUtil.java b/src/main/java/vazkii/quark/base/handler/MiscUtil.java index 253114b830..6ea1aa8f61 100644 --- a/src/main/java/vazkii/quark/base/handler/MiscUtil.java +++ b/src/main/java/vazkii/quark/base/handler/MiscUtil.java @@ -52,13 +52,16 @@ import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.items.wrapper.SidedInvWrapper; import vazkii.quark.base.Quark; -import vazkii.zeta.client.config.screen.ZetaScreen; import vazkii.quark.content.experimental.module.EnchantmentsBegoneModule; -import vazkii.zeta.client.event.ZScreenKeyPressed; +import vazkii.zeta.client.config.screen.ZetaScreen; +import vazkii.zeta.client.event.ZScreen; import vazkii.zeta.event.bus.PlayEvent; import javax.annotation.Nonnull; -import java.util.*; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; public class MiscUtil { @@ -227,7 +230,7 @@ public static class Client { private static int progress; @PlayEvent - public static void onKeystroke(ZScreenKeyPressed.Pre event) { + public static void onKeystroke(ZScreen.KeyPressed.Pre event) { final String[] ids = new String[] { "-FCYE87P5L0","mybsDDymrsc","6a4BWpBJppI","thpTOAS1Vgg","ZNcBZM5SvbY","_qJEoSa3Ie0", "RWeyOyY_puQ","VBbeuXW8Nko","LIDe-yTxda0","BVVfMFS3mgc","m5qwcYL8a0o","UkY8HvgvBJ8", diff --git a/src/main/java/vazkii/quark/base/module/LoadModule.java b/src/main/java/vazkii/quark/base/module/LoadModule.java index 05db94d9c9..1c745e8ccb 100644 --- a/src/main/java/vazkii/quark/base/module/LoadModule.java +++ b/src/main/java/vazkii/quark/base/module/LoadModule.java @@ -7,6 +7,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +@Deprecated(forRemoval = true) @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface LoadModule { diff --git a/src/main/java/vazkii/quark/content/automation/module/ChainsConnectBlocksModule.java b/src/main/java/vazkii/quark/content/automation/module/ChainsConnectBlocksModule.java index 7b3c8dc2b0..60512be76b 100644 --- a/src/main/java/vazkii/quark/content/automation/module/ChainsConnectBlocksModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/ChainsConnectBlocksModule.java @@ -1,9 +1,5 @@ package vazkii.quark.content.automation.module; -import java.util.function.Predicate; - -import org.apache.commons.lang3.tuple.Pair; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; import net.minecraft.world.item.Item; @@ -12,15 +8,18 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ChainBlock; import net.minecraft.world.level.block.state.BlockState; +import org.apache.commons.lang3.tuple.Pair; import vazkii.zeta.api.IIndirectConnector; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import java.util.function.Predicate; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class ChainsConnectBlocksModule extends ZetaModule { @Hint Item chain = Items.CHAIN; diff --git a/src/main/java/vazkii/quark/content/automation/module/ChuteModule.java b/src/main/java/vazkii/quark/content/automation/module/ChuteModule.java index 65ff029e3e..a357475570 100644 --- a/src/main/java/vazkii/quark/content/automation/module/ChuteModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/ChuteModule.java @@ -7,19 +7,19 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.material.Material; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.ChuteBlock; import vazkii.quark.content.automation.block.be.ChuteBlockEntity; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; /** * @author WireSegal * Created at 10:25 AM on 9/29/19. */ -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class ChuteModule extends ZetaModule { public static BlockEntityType blockEntityType; diff --git a/src/main/java/vazkii/quark/content/automation/module/DispensersPlaceBlocksModule.java b/src/main/java/vazkii/quark/content/automation/module/DispensersPlaceBlocksModule.java index 0f200e9d4a..03933e4a15 100644 --- a/src/main/java/vazkii/quark/content/automation/module/DispensersPlaceBlocksModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/DispensersPlaceBlocksModule.java @@ -19,7 +19,7 @@ import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.SlabBlock; import net.minecraft.world.level.block.StairBlock; -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.ZCommonSetup; @@ -30,7 +30,7 @@ import java.util.Map; import java.util.Objects; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class DispensersPlaceBlocksModule extends ZetaModule { @Config public static List blacklist = Lists.newArrayList("minecraft:water", "minecraft:lava", "minecraft:fire"); diff --git a/src/main/java/vazkii/quark/content/automation/module/EnderWatcherModule.java b/src/main/java/vazkii/quark/content/automation/module/EnderWatcherModule.java index 0f2ae20463..3822a46918 100644 --- a/src/main/java/vazkii/quark/content/automation/module/EnderWatcherModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/EnderWatcherModule.java @@ -6,15 +6,15 @@ import vazkii.quark.base.Quark; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.EnderWatcherBlock; import vazkii.quark.content.automation.block.be.EnderWatcherBlockEntity; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class EnderWatcherModule extends ZetaModule { public static BlockEntityType blockEntityType; diff --git a/src/main/java/vazkii/quark/content/automation/module/FeedingTroughModule.java b/src/main/java/vazkii/quark/content/automation/module/FeedingTroughModule.java index a340eedc9a..a9ed0a13f0 100644 --- a/src/main/java/vazkii/quark/content/automation/module/FeedingTroughModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/FeedingTroughModule.java @@ -1,14 +1,8 @@ package vazkii.quark.content.automation.module; -import java.util.Set; -import java.util.function.Predicate; - -import javax.annotation.Nullable; - import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.mojang.datafixers.util.Pair; - import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.Registry; @@ -35,26 +29,29 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.event.entity.EntityJoinLevelEvent; -import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.FeedingTroughBlock; import vazkii.quark.content.automation.block.be.FeedingTroughBlockEntity; +import vazkii.zeta.event.ZBabyEntitySpawn; +import vazkii.zeta.event.ZEntityJoinLevel; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import javax.annotation.Nullable; +import java.util.Set; +import java.util.function.Predicate; /** * @author WireSegal * Created at 9:48 AM on 9/20/19. */ -@LoadModule(category = "automation", hasSubscriptions = true) +@ZetaLoadModule(category = "automation") public class FeedingTroughModule extends ZetaModule { public static BlockEntityType blockEntityType; @@ -84,14 +81,14 @@ public class FeedingTroughModule extends ZetaModule { private static final ThreadLocal breedingOccurred = ThreadLocal.withInitial(() -> false); - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onBreed(BabyEntitySpawnEvent event) { + @PlayEvent + public void onBreed(ZBabyEntitySpawn.Lowest event) { if (event.getCausedByPlayer() == null && event.getParentA().level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) breedingOccurred.set(true); } - @SubscribeEvent - public void onOrbSpawn(EntityJoinLevelEvent event) { + @PlayEvent + public void onOrbSpawn(ZEntityJoinLevel event) { if (event.getEntity() instanceof ExperienceOrb && breedingOccurred.get()) { event.setCanceled(true); breedingOccurred.remove(); @@ -174,7 +171,7 @@ private static Set getBlockStates(Block p_218074_) { return ImmutableSet.copyOf(p_218074_.getStateDefinition().getPossibleStates()); } - private static record TroughPointer(BlockPos pos, FakePlayer player) { + private record TroughPointer(BlockPos pos, FakePlayer player) { public boolean exists() { return player != null; diff --git a/src/main/java/vazkii/quark/content/automation/module/GravisandModule.java b/src/main/java/vazkii/quark/content/automation/module/GravisandModule.java index d32151350c..10e83aeba9 100755 --- a/src/main/java/vazkii/quark/content/automation/module/GravisandModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/GravisandModule.java @@ -9,16 +9,16 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.GravisandBlock; import vazkii.quark.content.automation.entity.Gravisand; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class GravisandModule extends ZetaModule { public static EntityType gravisandType; @@ -38,8 +38,12 @@ public final void register(ZRegister event) { Quark.ZETA.registry.register(gravisandType, "gravisand", Registry.ENTITY_TYPE_REGISTRY); } - @LoadEvent - public final void clientSetup(ZClientSetup event) { - EntityRenderers.register(gravisandType, FallingBlockRenderer::new); + + @ZetaLoadModule(clientReplacement = true) + public static class Client extends GravisandModule { + @LoadEvent + public final void clientSetup(ZClientSetup event) { + EntityRenderers.register(gravisandType, FallingBlockRenderer::new); + } } } diff --git a/src/main/java/vazkii/quark/content/automation/module/IronRodModule.java b/src/main/java/vazkii/quark/content/automation/module/IronRodModule.java index 608fa29895..3b7deefc16 100644 --- a/src/main/java/vazkii/quark/content/automation/module/IronRodModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/IronRodModule.java @@ -5,16 +5,16 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.IronRodBlock; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class IronRodModule extends ZetaModule { public static TagKey ironRodImmuneTag; diff --git a/src/main/java/vazkii/quark/content/automation/module/JukeboxAutomationModule.java b/src/main/java/vazkii/quark/content/automation/module/JukeboxAutomationModule.java index f6ce5037ff..0b46e34ad5 100644 --- a/src/main/java/vazkii/quark/content/automation/module/JukeboxAutomationModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/JukeboxAutomationModule.java @@ -22,19 +22,19 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.event.AttachCapabilitiesEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.items.IItemHandler; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; +import vazkii.zeta.event.ZAttachCapabilities; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; import javax.annotation.Nonnull; -@LoadModule(category = "automation", hasSubscriptions = true) +@ZetaLoadModule(category = "automation") public class JukeboxAutomationModule extends ZetaModule { @Hint Item jukebox = Items.JUKEBOX; @@ -50,8 +50,8 @@ public void setup(ZCommonSetup e) { })); } - @SubscribeEvent - public void attachCaps(AttachCapabilitiesEvent event) { + @PlayEvent + public void attachCaps(ZAttachCapabilities event) { if(event.getObject() instanceof JukeboxBlockEntity jukebox) event.addCapability(JUKEBOX_ITEM_HANDLER, new JukeboxItemHandler(jukebox)); } diff --git a/src/main/java/vazkii/quark/content/automation/module/MetalButtonsModule.java b/src/main/java/vazkii/quark/content/automation/module/MetalButtonsModule.java index 013da283e1..a013eb8ea3 100755 --- a/src/main/java/vazkii/quark/content/automation/module/MetalButtonsModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/MetalButtonsModule.java @@ -1,15 +1,15 @@ package vazkii.quark.content.automation.module; import net.minecraft.world.level.block.Block; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.MetalButtonBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class MetalButtonsModule extends ZetaModule { @Config(flag = "iron_metal_button") diff --git a/src/main/java/vazkii/quark/content/automation/module/ObsidianPlateModule.java b/src/main/java/vazkii/quark/content/automation/module/ObsidianPlateModule.java index 007c5f7c81..27d62648ac 100644 --- a/src/main/java/vazkii/quark/content/automation/module/ObsidianPlateModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/ObsidianPlateModule.java @@ -4,17 +4,17 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.automation.block.ObsidianPressurePlateBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; /** * @author WireSegal * Created at 9:51 PM on 10/8/19. */ -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class ObsidianPlateModule extends ZetaModule { @LoadEvent public final void register(ZRegister event) { diff --git a/src/main/java/vazkii/quark/content/automation/module/PistonsMoveTileEntitiesModule.java b/src/main/java/vazkii/quark/content/automation/module/PistonsMoveTileEntitiesModule.java index 7d44d91558..985fc16dab 100644 --- a/src/main/java/vazkii/quark/content/automation/module/PistonsMoveTileEntitiesModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/PistonsMoveTileEntitiesModule.java @@ -17,31 +17,29 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.ChestType; import net.minecraftforge.common.util.NonNullConsumer; -import net.minecraftforge.event.TickEvent.LevelTickEvent; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.eventbus.api.SubscribeEvent; import org.apache.commons.lang3.tuple.Pair; -import vazkii.zeta.api.IIndirectConnector; import vazkii.quark.api.IPistonCallback; import vazkii.quark.api.QuarkCapabilities; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.content.building.module.SturdyStoneModule; +import vazkii.zeta.api.IIndirectConnector; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZGatherHints; +import vazkii.zeta.event.ZLevelTick; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import vazkii.zeta.piston.ZetaPistonStructureResolver; import javax.annotation.Nullable; import java.util.*; import java.util.function.Predicate; -@LoadModule(category = "automation", hasSubscriptions = true) +@ZetaLoadModule(category = "automation") public class PistonsMoveTileEntitiesModule extends ZetaModule { private static final WeakHashMap> movements = new WeakHashMap<>(); @@ -69,21 +67,21 @@ public final void configChanged(ZConfigChanged event) { staticEnabled = enabled; } - @SubscribeEvent - public void onWorldTick(LevelTickEvent event) { - if (!delayedUpdates.containsKey(event.level) || event.phase == Phase.START) + @PlayEvent + public void onWorldTick(ZLevelTick.End event) { + if (!delayedUpdates.containsKey(event.getLevel())) return; - List> delays = delayedUpdates.get(event.level); + List> delays = delayedUpdates.get(event.getLevel()); if (delays.isEmpty()) return; for (Pair delay : delays) { BlockPos pos = delay.getLeft(); - BlockState state = event.level.getBlockState(pos); - BlockEntity entity = loadBlockEntitySafe(event.level, pos, delay.getRight()); + BlockState state = event.getLevel().getBlockState(pos); + BlockEntity entity = loadBlockEntitySafe(event.getLevel(), pos, delay.getRight()); callCallback(entity, IPistonCallback::onPistonMovementFinished); - event.level.updateNeighbourForOutputSignal(pos, state.getBlock()); + event.getLevel().updateNeighbourForOutputSignal(pos, state.getBlock()); } delays.clear(); diff --git a/src/main/java/vazkii/quark/content/automation/module/RedstoneRandomizerModule.java b/src/main/java/vazkii/quark/content/automation/module/RedstoneRandomizerModule.java index 14ffc33773..0deb093308 100644 --- a/src/main/java/vazkii/quark/content/automation/module/RedstoneRandomizerModule.java +++ b/src/main/java/vazkii/quark/content/automation/module/RedstoneRandomizerModule.java @@ -4,18 +4,18 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.material.Material; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.automation.block.RedstoneRandomizerBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; /** * @author WireSegal * Created at 10:34 AM on 8/26/19. */ -@LoadModule(category = "automation") +@ZetaLoadModule(category = "automation") public class RedstoneRandomizerModule extends ZetaModule { @Hint Block redstone_randomizer; diff --git a/src/main/java/vazkii/quark/content/building/module/BambooBackportModule.java b/src/main/java/vazkii/quark/content/building/module/BambooBackportModule.java index 44f974f063..1d8e6305df 100644 --- a/src/main/java/vazkii/quark/content/building/module/BambooBackportModule.java +++ b/src/main/java/vazkii/quark/content/building/module/BambooBackportModule.java @@ -6,12 +6,12 @@ import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.WoodSetHandler; import vazkii.quark.base.handler.WoodSetHandler.WoodSet; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class BambooBackportModule extends ZetaModule { public static WoodSet woodSet; diff --git a/src/main/java/vazkii/quark/content/building/module/CelebratoryLampsModule.java b/src/main/java/vazkii/quark/content/building/module/CelebratoryLampsModule.java index 71024bf460..e026d12bc8 100644 --- a/src/main/java/vazkii/quark/content/building/module/CelebratoryLampsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/CelebratoryLampsModule.java @@ -7,18 +7,16 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; +import vazkii.zeta.event.ZItemTooltip; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building", hasSubscriptions = true, subscribeOn = Dist.CLIENT) +@ZetaLoadModule(category = "building") public class CelebratoryLampsModule extends ZetaModule { @Config @@ -31,15 +29,17 @@ public final void register(ZRegister event) { stone_lamp = new QuarkBlock("stone_lamp", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.copy(Blocks.STONE).lightLevel(s -> lightLevel)); stone_brick_lamp = new QuarkBlock("stone_brick_lamp", this, CreativeModeTab.TAB_BUILDING_BLOCKS, Block.Properties.copy(Blocks.STONE_BRICKS).lightLevel(s -> lightLevel)); } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onTooltip(ItemTooltipEvent event) { - if(event.getFlags().isAdvanced()) { - ItemStack stack = event.getItemStack(); - Item item = stack.getItem(); - if(item == stone_lamp.asItem() || item == stone_brick_lamp.asItem()) - event.getToolTip().add(1, Component.translatable("quark.misc.celebration").withStyle(ChatFormatting.GRAY)); + + @ZetaLoadModule(clientReplacement = true) + public static class Client extends CelebratoryLampsModule { + @PlayEvent + public void onTooltip(ZItemTooltip event) { + if(event.getFlags().isAdvanced()) { + ItemStack stack = event.getItemStack(); + Item item = stack.getItem(); + if(item == stone_lamp.asItem() || item == stone_brick_lamp.asItem()) + event.getToolTip().add(1, Component.translatable("quark.misc.celebration").withStyle(ChatFormatting.GRAY)); + } } } diff --git a/src/main/java/vazkii/quark/content/building/module/CompressedBlocksModule.java b/src/main/java/vazkii/quark/content/building/module/CompressedBlocksModule.java index 8d592c1503..5cc74273aa 100644 --- a/src/main/java/vazkii/quark/content/building/module/CompressedBlocksModule.java +++ b/src/main/java/vazkii/quark/content/building/module/CompressedBlocksModule.java @@ -1,10 +1,6 @@ package vazkii.quark.content.building.module; -import java.util.List; -import java.util.function.BooleanSupplier; - import com.google.common.collect.Lists; - import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.Block; @@ -18,15 +14,18 @@ import vazkii.quark.base.block.QuarkFlammablePillarBlock; import vazkii.quark.base.handler.FuelHandler; import vazkii.quark.base.handler.ToolInteractionHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.zeta.event.ZLoadComplete; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import java.util.List; +import java.util.function.BooleanSupplier; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class CompressedBlocksModule extends ZetaModule { @Config(name = "Charcoal Block and Blaze Lantern Stay On Fire Forever", flag = "compressed_blocks_burn_forever") diff --git a/src/main/java/vazkii/quark/content/building/module/DuskboundBlocksModule.java b/src/main/java/vazkii/quark/content/building/module/DuskboundBlocksModule.java index 947ece7bd8..c2e0214e31 100644 --- a/src/main/java/vazkii/quark/content/building/module/DuskboundBlocksModule.java +++ b/src/main/java/vazkii/quark/content/building/module/DuskboundBlocksModule.java @@ -5,12 +5,12 @@ import net.minecraft.world.level.block.Blocks; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class DuskboundBlocksModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/FramedGlassModule.java b/src/main/java/vazkii/quark/content/building/module/FramedGlassModule.java index df5e6c65be..2783382ccb 100755 --- a/src/main/java/vazkii/quark/content/building/module/FramedGlassModule.java +++ b/src/main/java/vazkii/quark/content/building/module/FramedGlassModule.java @@ -7,12 +7,12 @@ import net.minecraft.world.level.material.Material; import vazkii.quark.base.block.QuarkGlassBlock; import vazkii.quark.base.block.QuarkInheritedPaneBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class FramedGlassModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/GlassItemFrameModule.java b/src/main/java/vazkii/quark/content/building/module/GlassItemFrameModule.java index 1cefd4988c..96163bb5d2 100644 --- a/src/main/java/vazkii/quark/content/building/module/GlassItemFrameModule.java +++ b/src/main/java/vazkii/quark/content/building/module/GlassItemFrameModule.java @@ -6,26 +6,24 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraft.world.item.Item; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.client.render.entity.GlassItemFrameRenderer; import vazkii.quark.content.building.entity.GlassItemFrame; import vazkii.quark.content.building.item.QuarkItemFrameItem; -import vazkii.zeta.event.ZRegister; -import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.client.event.ZAddModels; import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.ZRegister; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; /** * @author WireSegal * Created at 11:00 AM on 8/25/19. */ -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class GlassItemFrameModule extends ZetaModule { @Config public static boolean glassItemFramesUpdateMaps = true; @@ -65,9 +63,12 @@ public final void clientSetup(ZClientSetup event) { EntityRenderers.register(glassFrameEntity, GlassItemFrameRenderer::new); } - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerAdditionalModels(ZAddModels event) { - event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/glass_item_frame", "inventory")); + @ZetaLoadModule(clientReplacement = true) + public static class Client extends GlassItemFrameModule { + @LoadEvent + public void registerAdditionalModels(ZAddModels event) { + event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/glass_item_frame", "inventory")); + } + } } diff --git a/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java b/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java index 72ffbb7941..999895de50 100644 --- a/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/GoldBarsModule.java @@ -9,15 +9,15 @@ import vazkii.quark.base.block.QuarkPaneBlock; import vazkii.quark.base.handler.StructureBlockReplacementHandler; import vazkii.quark.base.handler.StructureBlockReplacementHandler.StructureHolder; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import vazkii.zeta.registry.RenderLayerRegistry; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class GoldBarsModule extends ZetaModule { @Config public static boolean generateInNetherFortress = true; diff --git a/src/main/java/vazkii/quark/content/building/module/GrateModule.java b/src/main/java/vazkii/quark/content/building/module/GrateModule.java index ac8ac1bf53..4e463b3de5 100644 --- a/src/main/java/vazkii/quark/content/building/module/GrateModule.java +++ b/src/main/java/vazkii/quark/content/building/module/GrateModule.java @@ -1,18 +1,18 @@ package vazkii.quark.content.building.module; import net.minecraft.world.level.block.Block; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.block.GrateBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; /** * @author WireSegal * Created at 8:57 AM on 8/27/19. */ -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class GrateModule extends ZetaModule { @Hint public static Block grate; diff --git a/src/main/java/vazkii/quark/content/building/module/HollowLogsModule.java b/src/main/java/vazkii/quark/content/building/module/HollowLogsModule.java index 31a995da77..6530c1e6c2 100644 --- a/src/main/java/vazkii/quark/content/building/module/HollowLogsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/HollowLogsModule.java @@ -11,23 +11,22 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.event.TickEvent.PlayerTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.api.ICrawlSpaceBlock; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; import vazkii.quark.content.building.block.HollowLogBlock; import vazkii.zeta.event.ZCommonSetup; +import vazkii.zeta.event.ZPlayerTick; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; @LoadModule(category = "building", hasSubscriptions = true) public class HollowLogsModule extends ZetaModule { @@ -57,10 +56,10 @@ public final void setup(ZCommonSetup event) { hollowLogsTag = BlockTags.create(new ResourceLocation(Quark.MOD_ID, "hollow_logs")); } - @SubscribeEvent - public void playerTick(PlayerTickEvent event) { - if(enableAutoCrawl && event.phase == Phase.START) { - Player player = event.player; + @PlayEvent + public void playerTick(ZPlayerTick.Start event) { + if(enableAutoCrawl) { + Player player = event.getPlayer(); BlockPos playerPos = player.blockPosition(); boolean isTrying = player.isVisuallyCrawling() || (player.isCrouching() && !player.isColliding(playerPos, player.level.getBlockState(playerPos))); diff --git a/src/main/java/vazkii/quark/content/building/module/IndustrialPaletteModule.java b/src/main/java/vazkii/quark/content/building/module/IndustrialPaletteModule.java index cd184b01e1..9f0cb9746c 100644 --- a/src/main/java/vazkii/quark/content/building/module/IndustrialPaletteModule.java +++ b/src/main/java/vazkii/quark/content/building/module/IndustrialPaletteModule.java @@ -10,16 +10,16 @@ import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.block.QuarkPillarBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.content.building.block.VariantLadderBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import java.util.function.BooleanSupplier; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class IndustrialPaletteModule extends ZetaModule { private static final SoundType IRON_LADDER_SOUND_TYPE = new ForgeSoundType(1.0F, 1.0F, diff --git a/src/main/java/vazkii/quark/content/building/module/JapanesePaletteModule.java b/src/main/java/vazkii/quark/content/building/module/JapanesePaletteModule.java index 869e9546e8..7f7d8fab5f 100755 --- a/src/main/java/vazkii/quark/content/building/module/JapanesePaletteModule.java +++ b/src/main/java/vazkii/quark/content/building/module/JapanesePaletteModule.java @@ -10,11 +10,7 @@ */ package vazkii.quark.content.building.module; -import java.util.function.BooleanSupplier; - import vazkii.quark.base.block.IQuarkBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.content.building.block.BambooMatBlock; import vazkii.quark.content.building.block.BambooMatCarpetBlock; @@ -22,8 +18,12 @@ import vazkii.quark.content.building.block.PaperWallBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.function.BooleanSupplier; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class JapanesePaletteModule extends ZetaModule { @Config(flag = "paper_decor") diff --git a/src/main/java/vazkii/quark/content/building/module/MidoriModule.java b/src/main/java/vazkii/quark/content/building/module/MidoriModule.java index 934ceba3f6..63b6908f75 100644 --- a/src/main/java/vazkii/quark/content/building/module/MidoriModule.java +++ b/src/main/java/vazkii/quark/content/building/module/MidoriModule.java @@ -10,13 +10,13 @@ import vazkii.quark.base.block.QuarkPillarBlock; import vazkii.quark.base.handler.VariantHandler; import vazkii.quark.base.item.QuarkItem; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZLoadComplete; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class MidoriModule extends ZetaModule { private static Item moss_paste; diff --git a/src/main/java/vazkii/quark/content/building/module/MoreBrickTypesModule.java b/src/main/java/vazkii/quark/content/building/module/MoreBrickTypesModule.java index c76e8793d7..7235d30a52 100644 --- a/src/main/java/vazkii/quark/content/building/module/MoreBrickTypesModule.java +++ b/src/main/java/vazkii/quark/content/building/module/MoreBrickTypesModule.java @@ -1,20 +1,20 @@ package vazkii.quark.content.building.module; -import java.util.function.BooleanSupplier; - import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.function.BooleanSupplier; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class MoreBrickTypesModule extends ZetaModule { @Config(flag = "blue_nether_bricks", description = "This also comes with a utility recipe for Red Nether Bricks") diff --git a/src/main/java/vazkii/quark/content/building/module/MoreMudBlocksModule.java b/src/main/java/vazkii/quark/content/building/module/MoreMudBlocksModule.java index 82b6c39f5b..bc7f4a8f3b 100644 --- a/src/main/java/vazkii/quark/content/building/module/MoreMudBlocksModule.java +++ b/src/main/java/vazkii/quark/content/building/module/MoreMudBlocksModule.java @@ -6,13 +6,13 @@ import net.minecraft.world.level.block.state.BlockBehaviour.Properties; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.block.QuarkPillarBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.content.building.block.MudBrickLatticeBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class MoreMudBlocksModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/MorePottedPlantsModule.java b/src/main/java/vazkii/quark/content/building/module/MorePottedPlantsModule.java index d81e88b266..f78b05191d 100644 --- a/src/main/java/vazkii/quark/content/building/module/MorePottedPlantsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/MorePottedPlantsModule.java @@ -1,12 +1,7 @@ package vazkii.quark.content.building.module; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.google.common.base.Functions; import com.google.common.collect.Lists; - import net.minecraft.client.Minecraft; import net.minecraft.client.color.block.BlockColor; import net.minecraft.world.level.block.Block; @@ -14,14 +9,18 @@ import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class MorePottedPlantsModule extends ZetaModule { private static Map tintedBlocks = new HashMap<>(); diff --git a/src/main/java/vazkii/quark/content/building/module/MoreStoneVariantsModule.java b/src/main/java/vazkii/quark/content/building/module/MoreStoneVariantsModule.java index 98528aef4a..f1e0806932 100644 --- a/src/main/java/vazkii/quark/content/building/module/MoreStoneVariantsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/MoreStoneVariantsModule.java @@ -1,7 +1,5 @@ package vazkii.quark.content.building.module; -import java.util.function.BooleanSupplier; - import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -11,19 +9,21 @@ import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.block.QuarkPillarBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.quark.base.module.config.ConfigFlagManager; -import vazkii.zeta.event.ZGatherAdditionalFlags; -import vazkii.zeta.event.bus.PlayEvent; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; +import vazkii.quark.base.module.config.ConfigFlagManager; import vazkii.quark.content.building.block.MyalitePillarBlock; import vazkii.quark.content.world.block.MyaliteBlock; import vazkii.quark.content.world.module.NewStoneTypesModule; +import vazkii.zeta.event.ZGatherAdditionalFlags; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.function.BooleanSupplier; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class MoreStoneVariantsModule extends ZetaModule { @Config(flag = "stone_bricks") public boolean enableBricks = true; diff --git a/src/main/java/vazkii/quark/content/building/module/NetherBrickFenceGateModule.java b/src/main/java/vazkii/quark/content/building/module/NetherBrickFenceGateModule.java index f8516f6bc9..84f1f4281f 100644 --- a/src/main/java/vazkii/quark/content/building/module/NetherBrickFenceGateModule.java +++ b/src/main/java/vazkii/quark/content/building/module/NetherBrickFenceGateModule.java @@ -6,16 +6,16 @@ import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import vazkii.quark.base.block.QuarkFenceGateBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; /** * @author WireSegal * Created at 10:51 AM on 10/9/19. */ -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class NetherBrickFenceGateModule extends ZetaModule { @LoadEvent public final void register(ZRegister event) { diff --git a/src/main/java/vazkii/quark/content/building/module/RainbowLampsModule.java b/src/main/java/vazkii/quark/content/building/module/RainbowLampsModule.java index 61ced5af38..927047ab9d 100644 --- a/src/main/java/vazkii/quark/content/building/module/RainbowLampsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/RainbowLampsModule.java @@ -5,18 +5,18 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.base.util.CorundumColor; import vazkii.quark.content.building.block.RainbowLampBlock; import vazkii.quark.content.world.module.CorundumModule; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class RainbowLampsModule extends ZetaModule { @Config diff --git a/src/main/java/vazkii/quark/content/building/module/RawMetalBricksModule.java b/src/main/java/vazkii/quark/content/building/module/RawMetalBricksModule.java index 796bff7858..5b6be7af0e 100644 --- a/src/main/java/vazkii/quark/content/building/module/RawMetalBricksModule.java +++ b/src/main/java/vazkii/quark/content/building/module/RawMetalBricksModule.java @@ -1,19 +1,18 @@ package vazkii.quark.content.building.module; import com.google.common.collect.ImmutableSet; - import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockBehaviour.Properties; import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class RawMetalBricksModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/RopeModule.java b/src/main/java/vazkii/quark/content/building/module/RopeModule.java index c056919361..ff2658f061 100755 --- a/src/main/java/vazkii/quark/content/building/module/RopeModule.java +++ b/src/main/java/vazkii/quark/content/building/module/RopeModule.java @@ -1,7 +1,5 @@ package vazkii.quark.content.building.module; -import javax.annotation.Nonnull; - import net.minecraft.core.BlockPos; import net.minecraft.core.BlockSource; import net.minecraft.core.Direction; @@ -16,16 +14,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.block.RopeBlock; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import javax.annotation.Nonnull; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class RopeModule extends ZetaModule { @Hint public static Block rope; diff --git a/src/main/java/vazkii/quark/content/building/module/ShinglesModule.java b/src/main/java/vazkii/quark/content/building/module/ShinglesModule.java index e93c8a0f56..466c63dec8 100644 --- a/src/main/java/vazkii/quark/content/building/module/ShinglesModule.java +++ b/src/main/java/vazkii/quark/content/building/module/ShinglesModule.java @@ -5,12 +5,12 @@ import net.minecraft.world.level.block.Blocks; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class ShinglesModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/SoulSandstoneModule.java b/src/main/java/vazkii/quark/content/building/module/SoulSandstoneModule.java index 983e9e88f2..2bd3480136 100644 --- a/src/main/java/vazkii/quark/content/building/module/SoulSandstoneModule.java +++ b/src/main/java/vazkii/quark/content/building/module/SoulSandstoneModule.java @@ -6,12 +6,12 @@ import net.minecraft.world.level.material.MaterialColor; import vazkii.quark.base.block.QuarkBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class SoulSandstoneModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/StoolsModule.java b/src/main/java/vazkii/quark/content/building/module/StoolsModule.java index 6535915094..fc7f2a48e7 100644 --- a/src/main/java/vazkii/quark/content/building/module/StoolsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/StoolsModule.java @@ -12,21 +12,21 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.block.StoolBlock; import vazkii.quark.content.building.client.render.entity.StoolEntityRenderer; import vazkii.quark.content.building.entity.Stool; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; +import vazkii.zeta.event.ZRightClickBlock; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "building", hasSubscriptions = true) +@ZetaLoadModule(category = "building") public class StoolsModule extends ZetaModule { public static EntityType stoolEntity; @@ -53,8 +53,8 @@ public final void setup(ZCommonSetup event) { stoolsTag = ItemTags.create(new ResourceLocation(Quark.MOD_ID, "stools")); } - @SubscribeEvent - public void itemUsed(RightClickBlock event) { + @PlayEvent + public void itemUsed(ZRightClickBlock event) { if(event.getEntity().isShiftKeyDown() && event.getItemStack().getItem() instanceof BlockItem && event.getFace() == Direction.UP) { BlockState state = event.getLevel().getBlockState(event.getPos()); if(state.getBlock() instanceof StoolBlock stool) diff --git a/src/main/java/vazkii/quark/content/building/module/SturdyStoneModule.java b/src/main/java/vazkii/quark/content/building/module/SturdyStoneModule.java index 060a07e3ce..1f009d9621 100644 --- a/src/main/java/vazkii/quark/content/building/module/SturdyStoneModule.java +++ b/src/main/java/vazkii/quark/content/building/module/SturdyStoneModule.java @@ -1,14 +1,14 @@ package vazkii.quark.content.building.module; import net.minecraft.world.level.block.Block; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.block.SturdyStoneBlock; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class SturdyStoneModule extends ZetaModule { @Hint Block sturdy_stone; diff --git a/src/main/java/vazkii/quark/content/building/module/ThatchModule.java b/src/main/java/vazkii/quark/content/building/module/ThatchModule.java index 478d26c639..fef81865ee 100644 --- a/src/main/java/vazkii/quark/content/building/module/ThatchModule.java +++ b/src/main/java/vazkii/quark/content/building/module/ThatchModule.java @@ -2,15 +2,15 @@ import net.minecraft.world.level.block.ComposterBlock; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.content.building.block.ThatchBlock; import vazkii.zeta.event.ZLoadComplete; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building", antiOverlap = {"goated", "environmental"}) +@ZetaLoadModule(category = "building", antiOverlap = {"goated", "environmental"}) public class ThatchModule extends ZetaModule { @Config.Min(0) diff --git a/src/main/java/vazkii/quark/content/building/module/VariantBookshelvesModule.java b/src/main/java/vazkii/quark/content/building/module/VariantBookshelvesModule.java index 8cd79f0b4a..11d3c04852 100644 --- a/src/main/java/vazkii/quark/content/building/module/VariantBookshelvesModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VariantBookshelvesModule.java @@ -2,8 +2,6 @@ import net.minecraft.world.level.block.Blocks; import vazkii.quark.base.handler.ItemOverrideHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; @@ -11,8 +9,10 @@ import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building", antiOverlap = { "woodworks" }) +@ZetaLoadModule(category = "building", antiOverlap = { "woodworks" }) public class VariantBookshelvesModule extends ZetaModule { @Config public static boolean changeNames = true; diff --git a/src/main/java/vazkii/quark/content/building/module/VariantChestsModule.java b/src/main/java/vazkii/quark/content/building/module/VariantChestsModule.java index 80f24dd222..89a4a784bf 100644 --- a/src/main/java/vazkii/quark/content/building/module/VariantChestsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VariantChestsModule.java @@ -25,18 +25,10 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.structure.Structure; import net.minecraftforge.common.Tags; -import net.minecraftforge.event.entity.EntityJoinLevelEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; -import vazkii.quark.base.block.IQuarkBlock; import vazkii.quark.base.handler.StructureBlockReplacementHandler; import vazkii.quark.base.handler.StructureBlockReplacementHandler.StructureHolder; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.IDisableable; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; @@ -48,12 +40,14 @@ import vazkii.quark.content.building.recipe.MixedExclusionRecipe; import vazkii.quark.integration.lootr.ILootrIntegration; import vazkii.quark.mixin.accessor.AccessorAbstractChestedHorse; -import vazkii.zeta.event.ZConfigChanged; -import vazkii.zeta.event.ZLoadComplete; -import vazkii.zeta.event.ZRegister; -import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.client.event.ZPreTextureStitch; +import vazkii.zeta.event.*; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.IDisableable; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import javax.annotation.Nullable; import java.util.*; @@ -61,7 +55,7 @@ import java.util.function.Consumer; import java.util.function.Supplier; -@LoadModule(category = "building", hasSubscriptions = true, antiOverlap = { "woodworks" }) +@ZetaLoadModule(category = "building", antiOverlap = { "woodworks" }) public class VariantChestsModule extends ZetaModule { private static final String DONK_CHEST = "Quark:DonkChest"; @@ -256,8 +250,8 @@ public void textureStitch(ZPreTextureStitch event) { } } - @SubscribeEvent - public void onClickEntity(PlayerInteractEvent.EntityInteractSpecific event) { + @PlayEvent + public void onClickEntity(ZPlayerInteract.EntityInteractSpecific event) { Entity target = event.getTarget(); Player player = event.getEntity(); ItemStack held = player.getItemInHand(event.getHand()); @@ -287,8 +281,8 @@ public void onClickEntity(PlayerInteractEvent.EntityInteractSpecific event) { private static final ThreadLocal WAIT_TO_REPLACE_CHEST = new ThreadLocal<>(); - @SubscribeEvent - public void onDeath(LivingDeathEvent event) { + @PlayEvent + public void onDeath(ZLivingDeath event) { Entity target = event.getEntity(); if (target instanceof AbstractChestedHorse horse) { ItemStack chest = ItemStack.of(horse.getPersistentData().getCompound(DONK_CHEST)); @@ -297,8 +291,8 @@ public void onDeath(LivingDeathEvent event) { } } - @SubscribeEvent - public void onEntityJoinWorld(EntityJoinLevelEvent event) { + @PlayEvent + public void onEntityJoinWorld(ZEntityJoinLevel event) { Entity target = event.getEntity(); if (target instanceof ItemEntity item && item.getItem().getItem() == Items.CHEST) { ItemStack local = WAIT_TO_REPLACE_CHEST.get(); diff --git a/src/main/java/vazkii/quark/content/building/module/VariantFurnacesModule.java b/src/main/java/vazkii/quark/content/building/module/VariantFurnacesModule.java index b4246b2377..3eef2661be 100644 --- a/src/main/java/vazkii/quark/content/building/module/VariantFurnacesModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VariantFurnacesModule.java @@ -1,7 +1,5 @@ package vazkii.quark.content.building.module; -import java.util.function.ToIntFunction; - import net.minecraft.core.Registry; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -10,16 +8,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.content.building.block.SoulFurnaceBlock; import vazkii.quark.content.building.block.VariantFurnaceBlock; import vazkii.quark.content.building.block.be.VariantFurnaceBlockEntity; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import java.util.function.ToIntFunction; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class VariantFurnacesModule extends ZetaModule { public static BlockEntityType blockEntityType; diff --git a/src/main/java/vazkii/quark/content/building/module/VariantLaddersModule.java b/src/main/java/vazkii/quark/content/building/module/VariantLaddersModule.java index 88597f7f93..f84b314338 100644 --- a/src/main/java/vazkii/quark/content/building/module/VariantLaddersModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VariantLaddersModule.java @@ -1,8 +1,5 @@ package vazkii.quark.content.building.module; -import java.util.LinkedList; -import java.util.List; - import net.minecraft.core.BlockPos; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; @@ -12,8 +9,6 @@ import net.minecraft.world.level.block.state.BlockState; import vazkii.quark.base.handler.FuelHandler; import vazkii.quark.base.handler.ItemOverrideHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; @@ -22,8 +17,13 @@ import vazkii.zeta.event.ZLoadComplete; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.LinkedList; +import java.util.List; -@LoadModule(category = "building", antiOverlap = { "woodworks" }) +@ZetaLoadModule(category = "building", antiOverlap = { "woodworks" }) public class VariantLaddersModule extends ZetaModule { @Config public static boolean changeNames = true; diff --git a/src/main/java/vazkii/quark/content/building/module/VerticalPlanksModule.java b/src/main/java/vazkii/quark/content/building/module/VerticalPlanksModule.java index 48e999898d..d800b64e46 100644 --- a/src/main/java/vazkii/quark/content/building/module/VerticalPlanksModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VerticalPlanksModule.java @@ -3,14 +3,14 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.level.block.Block; import vazkii.quark.base.block.QuarkBlock; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "building", antiOverlap = { "woodworks" }) +@ZetaLoadModule(category = "building", antiOverlap = { "woodworks" }) public class VerticalPlanksModule extends ZetaModule { @LoadEvent diff --git a/src/main/java/vazkii/quark/content/building/module/VerticalSlabsModule.java b/src/main/java/vazkii/quark/content/building/module/VerticalSlabsModule.java index 157667d937..f5d3c3d74f 100644 --- a/src/main/java/vazkii/quark/content/building/module/VerticalSlabsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/VerticalSlabsModule.java @@ -1,13 +1,6 @@ package vazkii.quark.content.building.module; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.ImmutableSet; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -22,11 +15,10 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.block.state.properties.Property; import net.minecraftforge.common.ToolActions; +import org.apache.commons.lang3.tuple.Pair; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.ToolInteractionHandler; import vazkii.quark.base.handler.VariantHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.content.building.block.QuarkVerticalSlabBlock; import vazkii.quark.content.building.block.WeatheringCopperVerticalSlabBlock; @@ -34,8 +26,14 @@ import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class VerticalSlabsModule extends ZetaModule { @Config(description = "Should Walls and Panes attempt to connect to the side of Vertical Slabs?") diff --git a/src/main/java/vazkii/quark/content/building/module/WoodenPostsModule.java b/src/main/java/vazkii/quark/content/building/module/WoodenPostsModule.java index ec69a9bee3..cbe1977734 100644 --- a/src/main/java/vazkii/quark/content/building/module/WoodenPostsModule.java +++ b/src/main/java/vazkii/quark/content/building/module/WoodenPostsModule.java @@ -13,18 +13,18 @@ import net.minecraftforge.common.ToolActions; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.ToolInteractionHandler; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.util.Hint; import vazkii.quark.base.util.VanillaWoods; import vazkii.quark.base.util.VanillaWoods.Wood; import vazkii.quark.content.building.block.WoodPostBlock; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "building") +@ZetaLoadModule(category = "building") public class WoodenPostsModule extends ZetaModule { @Hint TagKey postsTag; diff --git a/src/main/java/vazkii/quark/content/client/module/AutoWalkKeybindModule.java b/src/main/java/vazkii/quark/content/client/module/AutoWalkKeybindModule.java index d7b7ac6a3a..a0dc47f964 100644 --- a/src/main/java/vazkii/quark/content/client/module/AutoWalkKeybindModule.java +++ b/src/main/java/vazkii/quark/content/client/module/AutoWalkKeybindModule.java @@ -11,8 +11,8 @@ import net.minecraft.world.entity.player.Player; import vazkii.quark.base.QuarkClient; import vazkii.zeta.client.event.ZInputUpdate; -import vazkii.zeta.client.event.ZRenderOverlay; -import vazkii.zeta.event.ZInputEvent; +import vazkii.zeta.client.event.ZRenderGuiOverlay; +import vazkii.zeta.client.event.ZInput; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; @@ -41,17 +41,17 @@ public void registerKeybinds(ZKeyMapping event) { } @PlayEvent - public void onMouseInput(ZInputEvent.MouseButton event) { + public void onMouseInput(ZInput.MouseButton event) { acceptInput(); } @PlayEvent - public void onKeyInput(ZInputEvent.Key event) { + public void onKeyInput(ZInput.Key event) { acceptInput(); } @PlayEvent - public void drawHUD(ZRenderOverlay.Hotbar event) { + public void drawHUD(ZRenderGuiOverlay.Hotbar event) { if(drawHud && autorunning) { String message = I18n.get("quark.misc.autowalking"); diff --git a/src/main/java/vazkii/quark/content/client/module/BackButtonKeybindModule.java b/src/main/java/vazkii/quark/content/client/module/BackButtonKeybindModule.java index 1dcb39e40d..269983b11b 100644 --- a/src/main/java/vazkii/quark/content/client/module/BackButtonKeybindModule.java +++ b/src/main/java/vazkii/quark/content/client/module/BackButtonKeybindModule.java @@ -1,26 +1,22 @@ package vazkii.quark.content.client.module; -import java.util.List; - -import org.lwjgl.glfw.GLFW; - import com.google.common.collect.ImmutableSet; import com.mojang.blaze3d.platform.InputConstants.Type; - import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.resources.language.I18n; +import org.lwjgl.glfw.GLFW; import vazkii.quark.base.QuarkClient; -import vazkii.zeta.client.event.ZScreenInit; -import vazkii.zeta.client.event.ZScreenKeyPressed; -import vazkii.zeta.client.event.ZScreenMousePressed; +import vazkii.zeta.client.event.ZKeyMapping; +import vazkii.zeta.client.event.ZScreen; +import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; -import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZKeyMapping; + +import java.util.List; @ZetaLoadModule(category = "client") public class BackButtonKeybindModule extends ZetaModule { @@ -38,18 +34,18 @@ public void registerKeybinds(ZKeyMapping event) { } @PlayEvent - public void openGui(ZScreenInit.Pre event) { + public void openGui(ZScreen.Init.Pre event) { listeners = event.getListenersList(); } @PlayEvent - public void onKeyInput(ZScreenKeyPressed.Post event) { + public void onKeyInput(ZScreen.KeyPressed.Post event) { if(backKey.getKey().getType() == Type.KEYSYM && event.getKeyCode() == backKey.getKey().getValue()) clicc(); } @PlayEvent - public void onMouseInput(ZScreenMousePressed.Post event) { + public void onMouseInput(ZScreen.MouseButtonPressed.Post event) { int btn = event.getButton(); if(backKey.getKey().getType() == Type.MOUSE && btn != GLFW.GLFW_MOUSE_BUTTON_LEFT && btn == backKey.getKey().getValue()) clicc(); diff --git a/src/main/java/vazkii/quark/content/client/module/CameraModule.java b/src/main/java/vazkii/quark/content/client/module/CameraModule.java index 257fd641a2..2cb2cf45ac 100644 --- a/src/main/java/vazkii/quark/content/client/module/CameraModule.java +++ b/src/main/java/vazkii/quark/content/client/module/CameraModule.java @@ -21,7 +21,7 @@ import vazkii.quark.base.handler.QuarkSounds; import vazkii.zeta.client.event.ZRenderTick; import vazkii.zeta.client.event.ZScreenshot; -import vazkii.zeta.event.ZInputEvent; +import vazkii.zeta.client.event.ZInput; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; @@ -122,7 +122,7 @@ public void screenshotTaken(ZScreenshot event) { } @PlayEvent - public void keystroke(ZInputEvent.Key event) { + public void keystroke(ZInput.Key event) { Minecraft mc = Minecraft.getInstance(); if(mc.level != null && event.getAction() == GLFW.GLFW_PRESS) { if(cameraModeKey.isDown()) { diff --git a/src/main/java/vazkii/quark/content/client/module/ChestSearchingModule.java b/src/main/java/vazkii/quark/content/client/module/ChestSearchingModule.java index a6ab1ba623..ba20502f9c 100644 --- a/src/main/java/vazkii/quark/content/client/module/ChestSearchingModule.java +++ b/src/main/java/vazkii/quark/content/client/module/ChestSearchingModule.java @@ -29,16 +29,6 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.EmptyHandler; import org.jetbrains.annotations.Nullable; -import vazkii.zeta.client.event.ZRenderContainerScreen; -import vazkii.zeta.client.event.ZScreenCharacterTyped; -import vazkii.zeta.client.event.ZScreenInit; -import vazkii.zeta.client.event.ZScreenKeyPressed; -import vazkii.zeta.client.event.ZScreenMousePressed; -import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; -import vazkii.zeta.event.bus.PlayEvent; -import vazkii.zeta.module.ZetaLoadModule; -import vazkii.zeta.util.ItemNBTHelper; import vazkii.quark.api.IQuarkButtonAllowed; import vazkii.quark.base.client.handler.InventoryButtonHandler; import vazkii.quark.base.client.handler.InventoryButtonHandler.ButtonTargetType; @@ -46,12 +36,20 @@ import vazkii.quark.base.handler.InventoryTransferHandler; import vazkii.quark.base.handler.MiscUtil; import vazkii.quark.base.handler.SimilarBlockTypeHandler; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.inputtable.RGBAColorConfig; import vazkii.quark.content.management.client.screen.widgets.MiniInventoryButton; +import vazkii.zeta.client.event.*; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.ItemNBTHelper; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.function.BiPredicate; import java.util.regex.Pattern; @@ -98,7 +96,7 @@ public final void clientSetup(ZClientSetup event) { } @PlayEvent - public void initGui(ZScreenInit.Post event) { + public void initGui(ZScreen.Init.Post event) { Screen gui = event.getScreen(); boolean apiAllowed = gui instanceof IQuarkButtonAllowed; if(!(gui instanceof InventoryScreen) && @@ -131,7 +129,7 @@ private void updateSearchStatus() { } @PlayEvent - public void charTyped(ZScreenCharacterTyped.Pre event) { + public void charTyped(ZScreen.CharacterTyped.Pre event) { if(searchBar != null && searchBar.isFocused() && searchEnabled) { searchBar.charTyped(event.getCodePoint(), event.getModifiers()); text = searchBar.getValue(); @@ -141,7 +139,7 @@ public void charTyped(ZScreenCharacterTyped.Pre event) { } @PlayEvent - public void onKeypress(ZScreenKeyPressed.Pre event) { + public void onKeypress(ZScreen.KeyPressed.Pre event) { if(searchBar != null && searchBar.isFocused() && searchEnabled) { searchBar.keyPressed(event.getKeyCode(), event.getScanCode(), event.getModifiers()); text = searchBar.getValue(); @@ -151,7 +149,7 @@ public void onKeypress(ZScreenKeyPressed.Pre event) { } @PlayEvent - public void onClick(ZScreenMousePressed.Pre event) { + public void onClick(ZScreen.MouseButtonPressed.Pre event) { if(searchBar != null && searchEnabled && event.getScreen() instanceof AbstractContainerScreen containerScreen) { searchBar.mouseClicked(event.getMouseX() - containerScreen.getGuiLeft(), event.getMouseY() - containerScreen.getGuiTop(), event.getButton()); diff --git a/src/main/java/vazkii/quark/content/client/module/ElytraIndicatorModule.java b/src/main/java/vazkii/quark/content/client/module/ElytraIndicatorModule.java index 5c0c1647df..005e3f4dab 100644 --- a/src/main/java/vazkii/quark/content/client/module/ElytraIndicatorModule.java +++ b/src/main/java/vazkii/quark/content/client/module/ElytraIndicatorModule.java @@ -10,7 +10,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import vazkii.quark.base.handler.MiscUtil; -import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderGuiOverlay; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; @@ -28,7 +28,7 @@ public static class Client extends ElytraIndicatorModule { private int shift = 0; @PlayEvent - public void hudPre(ZRenderOverlay.ArmorLevel.Pre event) { + public void hudPre(ZRenderGuiOverlay.ArmorLevel.Pre event) { if(!event.shouldDrawSurvivalElements()) return; @@ -59,7 +59,7 @@ public void hudPre(ZRenderOverlay.ArmorLevel.Pre event) { } @PlayEvent - public void hudPost(ZRenderOverlay.ArmorLevel.Post event) { + public void hudPost(ZRenderGuiOverlay.ArmorLevel.Post event) { if(shift != 0) { event.getPoseStack().translate(-shift, 0, 0); shift = 0; diff --git a/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java b/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java index 82285ada48..d4487abaea 100644 --- a/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java +++ b/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java @@ -1,18 +1,8 @@ package vazkii.quark.content.client.module; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Stack; -import java.util.function.BooleanSupplier; - -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.Lists; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.screens.Screen; @@ -30,15 +20,19 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import org.apache.commons.lang3.tuple.Pair; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.handler.MiscUtil; import vazkii.zeta.client.event.ZRenderContainerScreen; -import vazkii.zeta.client.event.ZScreenMousePressed; +import vazkii.zeta.client.event.ZScreen; import vazkii.zeta.client.event.ZStartClientTick; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; +import java.util.*; +import java.util.function.BooleanSupplier; + @ZetaLoadModule(category = "client") public class MicrocraftingHelperModule extends ZetaModule { @@ -52,7 +46,7 @@ public static class Client extends MicrocraftingHelperModule { private static int compoundCount = 1; @PlayEvent - public void onClick(ZScreenMousePressed.Pre event) { + public void onClick(ZScreen.MouseButtonPressed.Pre event) { Minecraft mc = Minecraft.getInstance(); Screen screen = mc.screen; diff --git a/src/main/java/vazkii/quark/content/client/module/UsageTickerModule.java b/src/main/java/vazkii/quark/content/client/module/UsageTickerModule.java index bfd8383279..ce97f9d252 100644 --- a/src/main/java/vazkii/quark/content/client/module/UsageTickerModule.java +++ b/src/main/java/vazkii/quark/content/client/module/UsageTickerModule.java @@ -13,7 +13,7 @@ import net.minecraft.world.item.enchantment.Enchantments; import vazkii.quark.api.IUsageTickerOverride; import vazkii.quark.base.Quark; -import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderGuiOverlay; import vazkii.zeta.client.event.ZStartClientTick; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; @@ -70,7 +70,7 @@ public void clientTick(ZStartClientTick event) { } @PlayEvent - public void renderHUD(ZRenderOverlay.Hotbar.Post event) { + public void renderHUD(ZRenderGuiOverlay.Hotbar.Post event) { Window window = event.getWindow(); Player player = Minecraft.getInstance().player; float partial = event.getPartialTick(); diff --git a/src/main/java/vazkii/quark/content/experimental/client/screen/VariantSelectorScreen.java b/src/main/java/vazkii/quark/content/experimental/client/screen/VariantSelectorScreen.java index d74f302052..ed595574d6 100644 --- a/src/main/java/vazkii/quark/content/experimental/client/screen/VariantSelectorScreen.java +++ b/src/main/java/vazkii/quark/content/experimental/client/screen/VariantSelectorScreen.java @@ -1,19 +1,9 @@ package vazkii.quark.content.experimental.client.screen; -import java.util.ArrayList; -import java.util.List; - -import org.lwjgl.opengl.GL11; - import com.google.common.collect.ImmutableSet; import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexFormat; - +import com.mojang.blaze3d.vertex.*; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; @@ -26,8 +16,12 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import org.lwjgl.opengl.GL11; import vazkii.quark.content.experimental.module.VariantSelectorModule; +import java.util.ArrayList; +import java.util.List; + public class VariantSelectorScreen extends Screen { float timeIn = 0; @@ -176,7 +170,7 @@ public void tick() { if(slotSelected != -1) { String variant = slotSelected == 0 ? "" : variants.get(slotSelected - 1); - VariantSelectorModule.setClientVariant(variant, true); + VariantSelectorModule.Client.setClientVariant(variant, true); mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } } diff --git a/src/main/java/vazkii/quark/content/experimental/module/AdjustableChatModule.java b/src/main/java/vazkii/quark/content/experimental/module/AdjustableChatModule.java index 076de900d3..e22e6f8441 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/AdjustableChatModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/AdjustableChatModule.java @@ -1,7 +1,7 @@ package vazkii.quark.content.experimental.module; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderGuiOverlay; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; @@ -16,12 +16,12 @@ public class AdjustableChatModule extends ZetaModule { public static class Client extends AdjustableChatModule { @PlayEvent - public void pre(ZRenderOverlay.Chat.Pre event) { + public void pre(ZRenderGuiOverlay.ChatPanel.Pre event) { event.getPoseStack().translate(horizontalShift, verticalShift, 0); } @PlayEvent - public void post(ZRenderOverlay.Chat.Post event) { + public void post(ZRenderGuiOverlay.ChatPanel.Post event) { event.getPoseStack().translate(-horizontalShift, -verticalShift, 0); } } diff --git a/src/main/java/vazkii/quark/content/experimental/module/EnchantmentsBegoneModule.java b/src/main/java/vazkii/quark/content/experimental/module/EnchantmentsBegoneModule.java index 0ab6356d8e..cd83954ec4 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/EnchantmentsBegoneModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/EnchantmentsBegoneModule.java @@ -9,12 +9,12 @@ import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.EnchantmentInstance; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.ZAnvilUpdate; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; import java.util.List; @@ -22,7 +22,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -@LoadModule(category = "experimental", enabledByDefault = false, hasSubscriptions = true) +@ZetaLoadModule(category = "experimental", enabledByDefault = false) public class EnchantmentsBegoneModule extends ZetaModule { @Config diff --git a/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java b/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java index 6526c26b64..f570273c1e 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java @@ -1,7 +1,6 @@ package vazkii.quark.content.experimental.module; import com.mojang.serialization.Dynamic; - import net.minecraft.ChatFormatting; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; @@ -20,10 +19,8 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; - import net.minecraftforge.eventbus.api.Event; import vazkii.quark.base.Quark; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.config.Config; import vazkii.zeta.event.*; import vazkii.zeta.event.bus.LoadEvent; @@ -37,7 +34,7 @@ import java.util.UUID; import java.util.function.Predicate; -@LoadModule(category = "experimental", enabledByDefault = false, hasSubscriptions = true) +@ZetaLoadModule(category = "experimental", enabledByDefault = false) public class GameNerfsModule extends ZetaModule { private static final String TAG_TRADES_ADJUSTED = "quark:zombie_trades_adjusted"; diff --git a/src/main/java/vazkii/quark/content/experimental/module/NarratorReadoutModule.java b/src/main/java/vazkii/quark/content/experimental/module/NarratorReadoutModule.java index cb851e9678..ebb2c3f8b1 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/NarratorReadoutModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/NarratorReadoutModule.java @@ -22,7 +22,7 @@ import net.minecraftforge.client.settings.KeyModifier; import vazkii.quark.base.QuarkClient; import vazkii.zeta.client.event.ZKeyMapping; -import vazkii.zeta.event.ZInputEvent; +import vazkii.zeta.client.event.ZInput; import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; @@ -47,7 +47,7 @@ public void registerKeybinds(ZKeyMapping event) { } @PlayEvent - public void onMouseInput(ZInputEvent.MouseButton event) { + public void onMouseInput(ZInput.MouseButton event) { boolean down = isDown(event.getButton(), 0, true, keybind); boolean full = isDown(event.getButton(), 0, true, keybindFull); @@ -55,7 +55,7 @@ public void onMouseInput(ZInputEvent.MouseButton event) { } @PlayEvent - public void onKeyInput(ZInputEvent.Key event) { + public void onKeyInput(ZInput.Key event) { boolean down = isDown(event.getKey(), event.getScanCode(), false, keybind); boolean full = isDown(event.getKey(), event.getScanCode(), false, keybindFull); diff --git a/src/main/java/vazkii/quark/content/experimental/module/VariantSelectorModule.java b/src/main/java/vazkii/quark/content/experimental/module/VariantSelectorModule.java index 7b848a94b3..3f63077c3d 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/VariantSelectorModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/VariantSelectorModule.java @@ -1,15 +1,8 @@ package vazkii.quark.content.experimental.module; -import java.util.Arrays; -import java.util.List; - -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL11; - import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.datafixers.util.Either; - import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -37,19 +30,11 @@ import net.minecraft.world.phys.HitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.InputEvent.Key; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; -import net.minecraftforge.client.event.RenderTooltipEvent; -import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay; -import net.minecraftforge.event.TickEvent.ClientTickEvent; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.event.entity.EntityJoinLevelEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import org.lwjgl.glfw.GLFW; +import org.lwjgl.opengl.GL11; import vazkii.quark.base.Quark; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.handler.MiscUtil; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.experimental.PlaceVariantUpdateMessage; @@ -57,13 +42,19 @@ import vazkii.quark.content.experimental.client.tooltip.VariantsComponent; import vazkii.quark.content.experimental.config.BlockSuffixConfig; import vazkii.quark.content.experimental.item.HammerItem; +import vazkii.zeta.client.event.*; import vazkii.zeta.event.ZConfigChanged; +import vazkii.zeta.event.ZEntityJoinLevel; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZKeyMapping; -import vazkii.zeta.client.event.ZTooltipComponents; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "experimental", hasSubscriptions = true, enabledByDefault = false, +import java.util.Arrays; +import java.util.List; + +@ZetaLoadModule(category = "experimental", enabledByDefault = false, description = "Allows placing variant blocks automatically via a selector menu triggered from a keybind") public class VariantSelectorModule extends ZetaModule { @@ -94,19 +85,11 @@ public class VariantSelectorModule extends ZetaModule { public static Item hammer; - @OnlyIn(Dist.CLIENT) - private static KeyMapping variantSelectorKey; - @LoadEvent public final void register(ZRegister event) { hammer = new HammerItem(this).setCondition(() -> enableHammer); } - @LoadEvent - public void registerKeybinds(ZKeyMapping event) { - variantSelectorKey = event.init("quark.keybind.variant_selector", "r", QuarkClient.MISC_GROUP); - } - @LoadEvent public final void configChanged(ZConfigChanged event) { staticEnabled = enabled; @@ -127,17 +110,6 @@ public static void setSavedVariant(ServerPlayer player, String variant) { player.getPersistentData().putString(TAG_CURRENT_VARIANT, variant); } - @OnlyIn(Dist.CLIENT) - public static void setClientVariant(String variant, boolean sync) { - clientVariant = variant; - - if(sync) { - if(variant == null) - variant = ""; - QuarkNetwork.sendToServer(new PlaceVariantUpdateMessage(variant)); - } - } - private static Block getMainHandVariantBlock(Player player, String variant) { ItemStack mainHand = player.getMainHandItem(); if(mainHand.getItem() instanceof BlockItem blockItem) { @@ -165,80 +137,25 @@ public static Block getVariantOrOriginal(Block block, String variant) { return getVariantForBlock(block, variant); } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void keystroke(Key event) { - Minecraft mc = Minecraft.getInstance(); - if(mc.level != null && event.getAction() == GLFW.GLFW_PRESS) { - if(variantSelectorKey.isDown()) { - - ItemStack stack = mc.player.getMainHandItem(); - if(stack.is(hammer)) { - HitResult result = mc.hitResult; - if(result instanceof BlockHitResult bhr) { - BlockPos pos = bhr.getBlockPos(); - Block block = mc.player.level.getBlockState(pos).getBlock(); - stack = new ItemStack(variants.getOriginalBlock(block)); - } - } - - if(!stack.isEmpty() && stack.getItem() instanceof BlockItem) - mc.setScreen(new VariantSelectorScreen(stack, variantSelectorKey, clientVariant, variants.getVisibleVariants())); + public static ItemStack modifyHeldItemStack(AbstractClientPlayer player, ItemStack stack) { + if(!staticEnabled || !overrideHeldItemRender) + return stack; - return; + Minecraft mc = Minecraft.getInstance(); + if(player == mc.player && stack.getItem() instanceof BlockItem bi) { + Block block = bi.getBlock(); + if(clientVariant != null && !clientVariant.isEmpty()) { + Block variant = variants.getBlockForVariant(block, clientVariant); + if(variant != null && variant != block) + return new ItemStack(variant); } } - } - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerClientTooltipComponentFactories(ZTooltipComponents event) { - event.register(VariantsComponent.class); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void gatherComponents(RenderTooltipEvent.GatherComponents event) { - if(!showTooltip) - return; - - ItemStack stack = event.getItemStack(); - - if(hasTooltip(stack)) { - List> elements = event.getTooltipElements(); - int index = 1; - - if(Screen.hasShiftDown()) { - elements.add(index, Either.left(Component.translatable("quark.misc.variant_tooltip_header").withStyle(ChatFormatting.GRAY))); - elements.add(index + 1, Either.right(new VariantsComponent(stack))); - } - else - elements.add(index, Either.left(Component.translatable("quark.misc.variant_tooltip_hold_shift").withStyle(ChatFormatting.GRAY))); - } - } - - private boolean hasTooltip(ItemStack stack) { - return !stack.isEmpty() && stack.getItem() instanceof BlockItem bi && !variants.getAllVariants(bi.getBlock()).isEmpty(); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void clientTick(ClientTickEvent event) { - if(event.phase != Phase.END) - return; - - Minecraft mc = Minecraft.getInstance(); - Level level = mc.level; - if(level == null) - setClientVariant(null, false); - else { - if(clientVariant == null) - setClientVariant("", true); - } + return stack; } - @SubscribeEvent - public void addEntityToWorld(EntityJoinLevelEvent event) { + @PlayEvent + public void addEntityToWorld(ZEntityJoinLevel event) { Entity entity = event.getEntity(); if(convertVariantItems && entity instanceof ItemEntity ie) { ItemStack stack = ie.getItem(); @@ -271,116 +188,183 @@ public static BlockState modifyBlockPlacementState(BlockState state, BlockPlaceC return state; } - - @OnlyIn(Dist.CLIENT) - public static ItemStack modifyHeldItemStack(AbstractClientPlayer player, ItemStack stack) { - if(!staticEnabled || !overrideHeldItemRender) - return stack; - - Minecraft mc = Minecraft.getInstance(); - if(player == mc.player && stack.getItem() instanceof BlockItem bi) { - Block block = bi.getBlock(); - if(clientVariant != null && !clientVariant.isEmpty()) { - Block variant = variants.getBlockForVariant(block, clientVariant); - if(variant != null && variant != block) - return new ItemStack(variant); + + @ZetaLoadModule(clientReplacement = true) + public static class Client extends VariantSelectorModule { + @OnlyIn(Dist.CLIENT) + private static KeyMapping variantSelectorKey; + + @LoadEvent + public void registerKeybinds(ZKeyMapping event) { + variantSelectorKey = event.init("quark.keybind.variant_selector", "r", QuarkClient.MISC_GROUP); + } + + public static void setClientVariant(String variant, boolean sync) { + clientVariant = variant; + + if(sync) { + if(variant == null) + variant = ""; + QuarkNetwork.sendToServer(new PlaceVariantUpdateMessage(variant)); } } - - return stack; - } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onRender(RenderGuiOverlayEvent.Pre event) { - Minecraft mc = Minecraft.getInstance(); - if(event.getOverlay() != VanillaGuiOverlay.CROSSHAIR.type() || mc.screen instanceof VariantSelectorScreen || !showHud) - return; + @PlayEvent + public void keystroke(ZInput.Key event) { + Minecraft mc = Minecraft.getInstance(); + if(mc.level != null && event.getAction() == GLFW.GLFW_PRESS) { + if(variantSelectorKey.isDown()) { + + ItemStack stack = mc.player.getMainHandItem(); + if(stack.is(hammer)) { + HitResult result = mc.hitResult; + if(result instanceof BlockHitResult bhr) { + BlockPos pos = bhr.getBlockPos(); + Block block = mc.player.level.getBlockState(pos).getBlock(); + stack = new ItemStack(variants.getOriginalBlock(block)); + } + } - Player player = mc.player; - String savedVariant = getSavedVariant(player); + if(!stack.isEmpty() && stack.getItem() instanceof BlockItem) + mc.setScreen(new VariantSelectorScreen(stack, variantSelectorKey, clientVariant, variants.getVisibleVariants())); - if(savedVariant != null) { - ItemStack mainHand = player.getMainHandItem(); - ItemStack displayLeft = mainHand.copy(); + return; + } + } + } + + @LoadEvent + public void registerClientTooltipComponentFactories(ZTooltipComponents event) { + event.register(VariantsComponent.class); + } + + @PlayEvent + public void gatherComponents(ZRenderTooltip.GatherComponents event) { + if(!showTooltip) + return; - Block variantBlock = null; + ItemStack stack = event.getItemStack(); - if(displayLeft.is(hammer)) { - HitResult result = mc.hitResult; - if(result instanceof BlockHitResult bhr) { - BlockPos pos = bhr.getBlockPos(); - Block testBlock = player.level.getBlockState(pos).getBlock(); + if(hasTooltip(stack)) { + List> elements = event.getTooltipElements(); + int index = 1; - displayLeft = new ItemStack(testBlock); - variantBlock = getVariantOrOriginal(testBlock, savedVariant); + if(Screen.hasShiftDown()) { + elements.add(index, Either.left(Component.translatable("quark.misc.variant_tooltip_header").withStyle(ChatFormatting.GRAY))); + elements.add(index + 1, Either.right(new VariantsComponent(stack))); } + else + elements.add(index, Either.left(Component.translatable("quark.misc.variant_tooltip_hold_shift").withStyle(ChatFormatting.GRAY))); } - else - variantBlock = getMainHandVariantBlock(player, savedVariant); + } - if(variantBlock != null) { - ItemStack displayRight = new ItemStack(variantBlock); + private boolean hasTooltip(ItemStack stack) { + return !stack.isEmpty() && stack.getItem() instanceof BlockItem bi && !variants.getAllVariants(bi.getBlock()).isEmpty(); + } - if(displayLeft.getItem() == displayRight.getItem()) - return; + @PlayEvent + public void clientTick(ZEndClientTick event) { + Minecraft mc = Minecraft.getInstance(); + Level level = mc.level; + if(level == null) + setClientVariant(null, false); + else { + if(clientVariant == null) + setClientVariant("", true); + } + } - Window window = event.getWindow(); - int x = window.getGuiScaledWidth() / 2; - int y = window.getGuiScaledHeight() / 2 + 12; - - - showSimpleHud = true; - alignHudToHotbar = true; - - if(alignHudToHotbar) { - HumanoidArm arm = mc.options.mainHand().get(); - if(arm == HumanoidArm.RIGHT) - x += 125; - else x -= 93; - - y = window.getGuiScaledHeight() - 19; + @PlayEvent + public void onRender(ZRenderGuiOverlay.Crosshair.Pre event) { + Minecraft mc = Minecraft.getInstance(); + if(mc.screen instanceof VariantSelectorScreen || !showHud) + return; + + Player player = mc.player; + String savedVariant = getSavedVariant(player); + + if(savedVariant != null) { + ItemStack mainHand = player.getMainHandItem(); + ItemStack displayLeft = mainHand.copy(); + + Block variantBlock = null; + + if(displayLeft.is(hammer)) { + HitResult result = mc.hitResult; + if(result instanceof BlockHitResult bhr) { + BlockPos pos = bhr.getBlockPos(); + Block testBlock = player.level.getBlockState(pos).getBlock(); + + displayLeft = new ItemStack(testBlock); + variantBlock = getVariantOrOriginal(testBlock, savedVariant); + } } - - int offset = 8; - int width = 16; - - displayLeft.setCount(1); - - int posX = x - offset - width; - int posY = y; - - if(!showSimpleHud) { - mc.getItemRenderer().renderAndDecorateItem(displayLeft, posX, posY); - - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 0.75F); - RenderSystem.setShaderTexture(0, MiscUtil.GENERAL_ICONS); - - Screen.blit(event.getPoseStack(), posX + 8, posY, 0, 141, 22, 15, 256, 256); - - posX += width * 2; - } - else { - final ResourceLocation WIDGETS_LOCATION = new ResourceLocation("textures/gui/widget.png"); - + else + variantBlock = getMainHandVariantBlock(player, savedVariant); + + if(variantBlock != null) { + ItemStack displayRight = new ItemStack(variantBlock); + + if(displayLeft.getItem() == displayRight.getItem()) + return; + + Window window = event.getWindow(); + int x = window.getGuiScaledWidth() / 2; + int y = window.getGuiScaledHeight() / 2 + 12; + + + showSimpleHud = true; + alignHudToHotbar = true; + if(alignHudToHotbar) { + HumanoidArm arm = mc.options.mainHand().get(); + if(arm == HumanoidArm.RIGHT) + x += 125; + else x -= 93; + + y = window.getGuiScaledHeight() - 19; + } + + int offset = 8; + int width = 16; + + displayLeft.setCount(1); + + int posX = x - offset - width; + int posY = y; + + if(!showSimpleHud) { + mc.getItemRenderer().renderAndDecorateItem(displayLeft, posX, posY); + RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.setShader(GameRenderer::getPositionTexShader); - if(enableGreenTint) - RenderSystem.setShaderColor(0.5F, 1.0F, 0.5F, 1.0F); - else - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, WIDGETS_LOCATION); - Screen.blit(event.getPoseStack(), posX -3, posY -3, 24, 23, 22, 22, 256, 256); - } else - posX += width; - } - - mc.getItemRenderer().renderAndDecorateItem(displayRight, posX , posY); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 0.75F); + RenderSystem.setShaderTexture(0, MiscUtil.GENERAL_ICONS); + + Screen.blit(event.getPoseStack(), posX + 8, posY, 0, 141, 22, 15, 256, 256); + + posX += width * 2; + } + else { + final ResourceLocation WIDGETS_LOCATION = new ResourceLocation("textures/gui/widget.png"); + + if(alignHudToHotbar) { + RenderSystem.enableBlend(); + RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + if(enableGreenTint) + RenderSystem.setShaderColor(0.5F, 1.0F, 0.5F, 1.0F); + else + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, WIDGETS_LOCATION); + Screen.blit(event.getPoseStack(), posX -3, posY -3, 24, 23, 22, 22, 256, 256); + } else + posX += width; + } + + mc.getItemRenderer().renderAndDecorateItem(displayRight, posX , posY); + } } } } diff --git a/src/main/java/vazkii/quark/content/experimental/module/VillagerRerollingReworkModule.java b/src/main/java/vazkii/quark/content/experimental/module/VillagerRerollingReworkModule.java index 51be93f047..60b0b7b514 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/VillagerRerollingReworkModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/VillagerRerollingReworkModule.java @@ -8,20 +8,16 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.item.trading.MerchantOffers; -import net.minecraftforge.event.entity.living.LivingConversionEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.event.ZLivingConversion; -import vazkii.zeta.event.ZLivingTick; -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.content.experimental.hax.PseudoAccessorMerchantOffer; import vazkii.quark.mixin.accessor.AccessorMerchantOffer; import vazkii.zeta.event.ZConfigChanged; +import vazkii.zeta.event.ZLivingConversion; +import vazkii.zeta.event.ZLivingTick; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; @ZetaLoadModule(category = "experimental", enabledByDefault = false) public class VillagerRerollingReworkModule extends ZetaModule { diff --git a/src/main/java/vazkii/quark/content/management/module/AutomaticToolRestockModule.java b/src/main/java/vazkii/quark/content/management/module/AutomaticToolRestockModule.java index 267d180772..e4f72b5a23 100644 --- a/src/main/java/vazkii/quark/content/management/module/AutomaticToolRestockModule.java +++ b/src/main/java/vazkii/quark/content/management/module/AutomaticToolRestockModule.java @@ -13,28 +13,27 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.ToolActions; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.event.TickEvent.PlayerTickEvent; -import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.PlayerInvWrapper; -import vazkii.quark.base.util.InventoryIIH; import vazkii.quark.addons.oddities.module.BackpackModule; import vazkii.quark.api.event.GatherToolClassesEvent; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.sync.SyncedFlagHandler; +import vazkii.quark.base.util.InventoryIIH; import vazkii.zeta.event.ZConfigChanged; +import vazkii.zeta.event.ZPlayerDestroyItem; +import vazkii.zeta.event.ZPlayerTick; import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import vazkii.zeta.util.RegistryUtil; import java.util.*; import java.util.function.Predicate; -@LoadModule(category = "management", hasSubscriptions = true, antiOverlap = "inventorytweaks") +@ZetaLoadModule(category = "management", antiOverlap = "inventorytweaks") public class AutomaticToolRestockModule extends ZetaModule { private static final Map ACTION_TO_CLASS = new HashMap<>(); @@ -86,8 +85,8 @@ public final void configChanged(ZConfigChanged event) { itemsToIgnore = RegistryUtil.massRegistryGet(ignoredItems, Registry.ITEM); } - @SubscribeEvent - public void onToolBreak(PlayerDestroyItemEvent event) { + @PlayEvent + public void onToolBreak(ZPlayerDestroyItem event) { Player player = event.getEntity(); ItemStack stack = event.getOriginal(); Item item = stack.getItem(); @@ -168,14 +167,14 @@ private boolean crawlInventory(IItemHandler inv, int lowerBound, int upperBound, return false; } - @SubscribeEvent - public void onPlayerTick(PlayerTickEvent event) { - if(event.phase == Phase.END && !event.player.level.isClientSide && replacements.containsKey(event.player)) { - Stack replacementStack = replacements.get(event.player); + @PlayEvent + public void onPlayerTick(ZPlayerTick.End event) { + if(!event.getPlayer().level.isClientSide && replacements.containsKey(event.getPlayer())) { + Stack replacementStack = replacements.get(event.getPlayer()); synchronized(mutex) { while(!replacementStack.isEmpty()) { QueuedRestock restock = replacementStack.pop(); - switchItems(event.player, restock); + switchItems(event.getPlayer(), restock); } } } diff --git a/src/main/java/vazkii/quark/content/management/module/EasyTransferingModule.java b/src/main/java/vazkii/quark/content/management/module/EasyTransferingModule.java index aedbfb1a79..21be02c459 100644 --- a/src/main/java/vazkii/quark/content/management/module/EasyTransferingModule.java +++ b/src/main/java/vazkii/quark/content/management/module/EasyTransferingModule.java @@ -2,55 +2,53 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.quark.base.client.handler.InventoryButtonHandler; import vazkii.quark.base.client.handler.InventoryButtonHandler.ButtonTargetType; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.InventoryTransferMessage; import vazkii.quark.content.management.client.screen.widgets.MiniInventoryButton; -import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.client.event.ZKeyMapping; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "management") +@ZetaLoadModule(category = "management") public class EasyTransferingModule extends ZetaModule { public static boolean shiftLocked = false; @Config public static boolean enableShiftLock = true; - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerKeybinds(ZKeyMapping event) { - addButton(event, 1, "insert", false); - addButton(event, 2, "extract", true); + @ZetaLoadModule(clientReplacement = true) + public static class Client extends EasyTransferingModule { + @LoadEvent + public void registerKeybinds(ZKeyMapping event) { + addButton(event, 1, "insert", false); + addButton(event, 2, "extract", true); InventoryButtonHandler.addButtonProvider(event, this, ButtonTargetType.CONTAINER_PLAYER_INVENTORY, 3, "quark.keybind.shift_lock", (screen) -> shiftLocked = !shiftLocked, (parent, x, y) -> new MiniInventoryButton(parent, 4, x, y, "quark.gui.button.shift_lock", (b) -> shiftLocked = !shiftLocked) - .setTextureShift(() -> shiftLocked), + .setTextureShift(() -> shiftLocked), () -> enableShiftLock); + } + + private void addButton(ZKeyMapping event, int priority, String name, boolean restock) { + InventoryButtonHandler.addButtonProvider(event, this, ButtonTargetType.CONTAINER_PLAYER_INVENTORY, priority, + "quark.keybind.transfer_" + name, + (screen) -> QuarkNetwork.sendToServer(new InventoryTransferMessage(Screen.hasShiftDown(), restock)), + (parent, x, y) -> new MiniInventoryButton(parent, priority, x, y, + (t) -> t.add(I18n.get("quark.gui.button." + name + (Screen.hasShiftDown() ? "_filtered" : ""))), + (b) -> QuarkNetwork.sendToServer(new InventoryTransferMessage(Screen.hasShiftDown(), restock))) + .setTextureShift(Screen::hasShiftDown), + null); + } + + public static boolean hasShiftDown(boolean ret) { + return ret || (enableShiftLock && shiftLocked); + } } - - @OnlyIn(Dist.CLIENT) - private void addButton(ZKeyMapping event, int priority, String name, boolean restock) { - InventoryButtonHandler.addButtonProvider(event, this, ButtonTargetType.CONTAINER_PLAYER_INVENTORY, priority, - "quark.keybind.transfer_" + name, - (screen) -> QuarkNetwork.sendToServer(new InventoryTransferMessage(Screen.hasShiftDown(), restock)), - (parent, x, y) -> new MiniInventoryButton(parent, priority, x, y, - (t) -> t.add(I18n.get("quark.gui.button." + name + (Screen.hasShiftDown() ? "_filtered" : ""))), - (b) -> QuarkNetwork.sendToServer(new InventoryTransferMessage(Screen.hasShiftDown(), restock))) - .setTextureShift(Screen::hasShiftDown), - null); - } - - public static boolean hasShiftDown(boolean ret) { - return ret || (enableShiftLock && shiftLocked); - } - } diff --git a/src/main/java/vazkii/quark/content/management/module/ExpandedItemInteractionsModule.java b/src/main/java/vazkii/quark/content/management/module/ExpandedItemInteractionsModule.java index 67a0057cad..6a668c711b 100644 --- a/src/main/java/vazkii/quark/content/management/module/ExpandedItemInteractionsModule.java +++ b/src/main/java/vazkii/quark/content/management/module/ExpandedItemInteractionsModule.java @@ -29,41 +29,38 @@ import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.RenderTooltipEvent; -import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.wrapper.EmptyHandler; import net.minecraftforge.network.NetworkHooks; -import vazkii.zeta.event.ZConfigChanged; -import vazkii.zeta.event.ZRegister; -import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; -import vazkii.zeta.util.ItemNBTHelper; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.GeneralConfig; import vazkii.quark.base.handler.SimilarBlockTypeHandler; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.ScrollOnBundleMessage; import vazkii.quark.content.management.client.screen.HeldShulkerBoxScreen; import vazkii.quark.content.management.inventory.HeldShulkerBoxContainer; import vazkii.quark.content.management.inventory.HeldShulkerBoxMenu; +import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.client.event.ZRenderTooltip; +import vazkii.zeta.client.event.ZScreen; +import vazkii.zeta.event.ZConfigChanged; +import vazkii.zeta.event.ZRegister; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; +import vazkii.zeta.util.ItemNBTHelper; import vazkii.zeta.util.RegistryUtil; import java.util.List; -@LoadModule(category = "management", hasSubscriptions = true) +@ZetaLoadModule(category = "management") public class ExpandedItemInteractionsModule extends ZetaModule { @Config @@ -131,39 +128,6 @@ public static boolean overrideOtherStackedOnMe(ItemStack stack, ItemStack incomi return enableShulkerBoxInteraction && shulkerOverride(stack, incoming, slot, action, player, true); } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onScroll(ScreenEvent.MouseScrolled.Pre event) { - if (!allowRotatingBundles) - return; - - Minecraft mc = Minecraft.getInstance(); - Screen gui = mc.screen; - - double scrollDelta = event.getScrollDelta(); - - if (mc.player != null && gui instanceof AbstractContainerScreen containerGui) { - Slot under = containerGui.getSlotUnderMouse(); - if (under != null) { - ItemStack underStack = under.getItem(); - if (underStack.is(Items.BUNDLE)) { - CompoundTag tag = underStack.getTag(); - if (tag != null) { - ListTag items = tag.getList("Items", Tag.TAG_COMPOUND); - if (items.size() > 1) { - var menu = containerGui.getMenu(); - event.setCanceled(true); - if (scrollDelta < -0.1 || scrollDelta > 0.1) { - rotateBundle(underStack, scrollDelta); - QuarkNetwork.sendToServer(new ScrollOnBundleMessage(menu.containerId, menu.getStateId(), under.index, scrollDelta)); - } - } - } - } - } - } - } - public static void scrollOnBundle(ServerPlayer player, int containerId, int stateId, int slotNum, double scrollDelta) { if (!staticEnabled || !allowRotatingBundles) return; @@ -218,63 +182,6 @@ private static void rotateBundle(ItemStack stack, double scrollDelta) { } } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onDrawScreen(ScreenEvent.Render.Post event) { - Minecraft mc = Minecraft.getInstance(); - Screen gui = mc.screen; - if (mc.player != null && gui instanceof AbstractContainerScreen containerGui) { - ItemStack held = containerGui.getMenu().getCarried(); - if (!held.isEmpty()) { - Slot under = containerGui.getSlotUnderMouse(); - - if (under != null) { - ItemStack underStack = under.getItem(); - - int x = event.getMouseX(); - int y = event.getMouseY(); - if (enableLavaInteraction && canTrashItem(underStack, held, under, mc.player)) { - gui.renderComponentTooltip(event.getPoseStack(), List.of(Component.translatable("quark.misc.trash_item").withStyle(ChatFormatting.RED)), x, y); - } else if (enableShulkerBoxInteraction && tryAddToShulkerBox(mc.player, underStack, held, under, true, true, true) != null) { - gui.renderComponentTooltip(event.getPoseStack(), List.of(Component.translatable( - SimilarBlockTypeHandler.isShulkerBox(held) ? "quark.misc.merge_shulker_box" : "quark.misc.insert_shulker_box" - ).withStyle(ChatFormatting.YELLOW)), x, y, underStack); - } else if (enableShulkerBoxInteraction && SimilarBlockTypeHandler.isShulkerBox(underStack)) { - gui.renderComponentTooltip(event.getPoseStack(), gui.getTooltipFromItem(underStack), x, y, underStack); - } - } - - } - } - } - - @SubscribeEvent(priority = EventPriority.LOW) - @OnlyIn(Dist.CLIENT) - public void gatherTooltip(RenderTooltipEvent.GatherComponents event) { - if (!enableArmorInteraction && (!enableShulkerBoxInteraction || !allowOpeningShulkerBoxes)) - return; - - Minecraft mc = Minecraft.getInstance(); - Screen gui = mc.screen; - if (mc.player != null && gui instanceof AbstractContainerScreen containerGui && containerGui.getMenu().getCarried().isEmpty()) { - Slot under = containerGui.getSlotUnderMouse(); - if (containerGui instanceof CreativeModeInventoryScreen creativeGui && creativeGui.getSelectedTab() != CreativeModeTab.TAB_INVENTORY.getId()) - return; - - if (under != null) { - ItemStack underStack = under.getItem(); - - if (event.getItemStack() == underStack) - if(enableArmorInteraction && armorOverride(underStack, ItemStack.EMPTY, under, ClickAction.SECONDARY, mc.player, true)) - event.getTooltipElements().add(Either.left(Component.translatable("quark.misc.equip_armor").withStyle(ChatFormatting.YELLOW))); - - else if(enableShulkerBoxInteraction && canOpenShulkerBox(underStack, ItemStack.EMPTY, under, mc.player)) - event.getTooltipElements().add(Either.left(Component.translatable("quark.misc.open_shulker").withStyle(ChatFormatting.YELLOW))); - } - } - } - - private static boolean armorOverride(ItemStack stack, ItemStack incoming, Slot slot, ClickAction action, Player player, boolean simulate) { if (incoming.isEmpty()) { //disallow stacks with more than one since it would prevent from de stacking @@ -457,4 +364,92 @@ private static ItemStack tryAddToShulkerBox(Player player, ItemStack shulkerBox, return null; } + @ZetaLoadModule(clientReplacement = true) + public static class Client extends ExpandedItemInteractionsModule { + @PlayEvent + public void gatherTooltip(ZRenderTooltip.GatherComponents.Low event) { + if (!enableArmorInteraction && (!enableShulkerBoxInteraction || !allowOpeningShulkerBoxes)) + return; + + Minecraft mc = Minecraft.getInstance(); + Screen gui = mc.screen; + if (mc.player != null && gui instanceof AbstractContainerScreen containerGui && containerGui.getMenu().getCarried().isEmpty()) { + Slot under = containerGui.getSlotUnderMouse(); + if (containerGui instanceof CreativeModeInventoryScreen creativeGui && creativeGui.getSelectedTab() != CreativeModeTab.TAB_INVENTORY.getId()) + return; + + if (under != null) { + ItemStack underStack = under.getItem(); + + if (event.getItemStack() == underStack) + if(enableArmorInteraction && armorOverride(underStack, ItemStack.EMPTY, under, ClickAction.SECONDARY, mc.player, true)) + event.getTooltipElements().add(Either.left(Component.translatable("quark.misc.equip_armor").withStyle(ChatFormatting.YELLOW))); + + else if(enableShulkerBoxInteraction && canOpenShulkerBox(underStack, ItemStack.EMPTY, under, mc.player)) + event.getTooltipElements().add(Either.left(Component.translatable("quark.misc.open_shulker").withStyle(ChatFormatting.YELLOW))); + } + } + } + + @PlayEvent + public void onDrawScreen(ZScreen.Render.Post event) { + Minecraft mc = Minecraft.getInstance(); + Screen gui = mc.screen; + if (mc.player != null && gui instanceof AbstractContainerScreen containerGui) { + ItemStack held = containerGui.getMenu().getCarried(); + if (!held.isEmpty()) { + Slot under = containerGui.getSlotUnderMouse(); + + if (under != null) { + ItemStack underStack = under.getItem(); + + int x = event.getMouseX(); + int y = event.getMouseY(); + if (enableLavaInteraction && canTrashItem(underStack, held, under, mc.player)) { + gui.renderComponentTooltip(event.getPoseStack(), List.of(Component.translatable("quark.misc.trash_item").withStyle(ChatFormatting.RED)), x, y); + } else if (enableShulkerBoxInteraction && tryAddToShulkerBox(mc.player, underStack, held, under, true, true, true) != null) { + gui.renderComponentTooltip(event.getPoseStack(), List.of(Component.translatable( + SimilarBlockTypeHandler.isShulkerBox(held) ? "quark.misc.merge_shulker_box" : "quark.misc.insert_shulker_box" + ).withStyle(ChatFormatting.YELLOW)), x, y, underStack); + } else if (enableShulkerBoxInteraction && SimilarBlockTypeHandler.isShulkerBox(underStack)) { + gui.renderComponentTooltip(event.getPoseStack(), gui.getTooltipFromItem(underStack), x, y, underStack); + } + } + + } + } + } + + @PlayEvent + public void onScroll(ZScreen.MouseScrolled.Pre event) { + if (!allowRotatingBundles) + return; + + Minecraft mc = Minecraft.getInstance(); + Screen gui = mc.screen; + + double scrollDelta = event.getScrollDelta(); + + if (mc.player != null && gui instanceof AbstractContainerScreen containerGui) { + Slot under = containerGui.getSlotUnderMouse(); + if (under != null) { + ItemStack underStack = under.getItem(); + if (underStack.is(Items.BUNDLE)) { + CompoundTag tag = underStack.getTag(); + if (tag != null) { + ListTag items = tag.getList("Items", Tag.TAG_COMPOUND); + if (items.size() > 1) { + var menu = containerGui.getMenu(); + event.setCanceled(true); + if (scrollDelta < -0.1 || scrollDelta > 0.1) { + rotateBundle(underStack, scrollDelta); + QuarkNetwork.sendToServer(new ScrollOnBundleMessage(menu.containerId, menu.getStateId(), under.index, scrollDelta)); + } + } + } + } + } + } + } + } } diff --git a/src/main/java/vazkii/quark/content/management/module/HotbarChangerModule.java b/src/main/java/vazkii/quark/content/management/module/HotbarChangerModule.java index fab9582393..9c31ca736f 100644 --- a/src/main/java/vazkii/quark/content/management/module/HotbarChangerModule.java +++ b/src/main/java/vazkii/quark/content/management/module/HotbarChangerModule.java @@ -1,11 +1,8 @@ package vazkii.quark.content.management.module; -import org.lwjgl.opengl.GL11; - import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; @@ -15,29 +12,21 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -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.gui.overlay.NamedGuiOverlay; -import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay; -import net.minecraftforge.event.TickEvent.ClientTickEvent; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import org.lwjgl.opengl.GL11; import vazkii.quark.base.QuarkClient; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.ChangeHotbarMessage; -import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.client.event.ZEndClientTick; +import vazkii.zeta.client.event.ZInput; import vazkii.zeta.client.event.ZKeyMapping; +import vazkii.zeta.client.event.ZRenderGuiOverlay; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "management", hasSubscriptions = true, subscribeOn = Dist.CLIENT) +@ZetaLoadModule(category = "management") public class HotbarChangerModule extends ZetaModule { - - @OnlyIn(Dist.CLIENT) - private static KeyMapping changeHotbarKey; - private static final ResourceLocation WIDGETS = new ResourceLocation("textures/gui/widget.png"); private static final int ANIMATION_TIME = 10; @@ -50,77 +39,62 @@ public class HotbarChangerModule extends ZetaModule { public static boolean keyDown; public static boolean hotbarChangeOpen, shifting; - @LoadEvent - public void registerKeybinds(ZKeyMapping event) { - changeHotbarKey = event.init("quark.keybind.change_hotbar", "z", QuarkClient.MISC_GROUP); - } + @ZetaLoadModule(clientReplacement = true) + public static class Client extends HotbarChangerModule { + private static KeyMapping changeHotbarKey; - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onMouseInput(InputEvent.MouseButton event) { - acceptInput(-1); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onKeyInput(InputEvent.Key event) { - acceptInput(event.getKey()); - } + @LoadEvent + public void registerKeybinds(ZKeyMapping event) { + changeHotbarKey = event.init("quark.keybind.change_hotbar", "z", QuarkClient.MISC_GROUP); + } - private void acceptInput(int currInput) { - Minecraft mc = Minecraft.getInstance(); - boolean down = changeHotbarKey.isDown(); - boolean wasDown = keyDown; - keyDown = down; - if(mc.isWindowActive()) { - if(down && !wasDown) - hotbarChangeOpen = !hotbarChangeOpen; - else if(hotbarChangeOpen) - for(int i = 0; i < 3; i++) - if(isKeyDownOrFallback(mc.options.keyHotbarSlots[i], 49 + i, currInput)) { - QuarkNetwork.sendToServer(new ChangeHotbarMessage(i + 1)); - hotbarChangeOpen = false; - currentHeldItem = mc.player.getInventory().selected; - return; - } + @PlayEvent + public void onMouseInput(ZInput.MouseButton event) { + acceptInput(-1); + } + @PlayEvent + public void onKeyInput(ZInput.Key event) { + acceptInput(event.getKey()); } - } - - private boolean isKeyDownOrFallback(KeyMapping key, int input, int currInput) { - if(key.isUnbound()) - return currInput != -1 && input == currInput; - - return key.isDown(); - } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void hudPre(RenderGuiOverlayEvent.Pre event) { - float shift = -getRealHeight(event.getPartialTick()) + 22; - if(shift < 0) { - NamedGuiOverlay overlay = event.getOverlay(); - if(overlay == VanillaGuiOverlay.PLAYER_HEALTH.type()) { + //fixme Needs splitting up + @PlayEvent + public void hudHeathPre(ZRenderGuiOverlay.PlayerHealth.Pre event) { + float shift = -getRealHeight(event.getPartialTick()) + 22; + if (shift < 0) { event.getPoseStack().translate(0, shift, 0); shifting = true; - } else if(shifting && (overlay == VanillaGuiOverlay.DEBUG_TEXT.type() || overlay == VanillaGuiOverlay.POTION_ICONS.type())) { + } + } + + @PlayEvent + public void hudDebugTextPre(ZRenderGuiOverlay.DebugText.Pre event) { + hudOverlay(event); + } + + @PlayEvent + public void hudPotionIconsPre(ZRenderGuiOverlay.PotionIcons.Pre event) { + hudOverlay(event); + } + + public void hudOverlay(ZRenderGuiOverlay event) { + float shift = -getRealHeight(event.getPartialTick()) + 22; + if (shifting) { event.getPoseStack().translate(0, -shift, 0); shifting = false; } } - } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void hudPost(RenderGuiOverlayEvent.Post event) { - if(height <= 0) - return; + @PlayEvent + public void hudPost(ZRenderGuiOverlay.Hotbar.Post event) { + if(height <= 0) + return; - Minecraft mc = Minecraft.getInstance(); - Player player = mc.player; - PoseStack matrix = event.getPoseStack(); + Minecraft mc = Minecraft.getInstance(); + Player player = mc.player; + PoseStack matrix = event.getPoseStack(); - if(event.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) { Window res = event.getWindow(); float realHeight = getRealHeight(event.getPartialTick()); float xStart = res.getGuiScaledWidth() / 2f - 91; @@ -149,9 +123,9 @@ public void hudPost(RenderGuiOverlayEvent.Post event) { if(!key.isUnbound()) { draw = key.getTranslatedKeyMessage().getString(); } - + draw = ChatFormatting.BOLD + draw; - + mc.font.drawShadow(matrix, draw, xStart - mc.font.width(draw) - 2, yStart + i * 21 + 7, 0xFFFFFF); } @@ -164,37 +138,60 @@ public void hudPost(RenderGuiOverlayEvent.Post event) { render.renderGuiItemDecorations(mc.font, invStack, x, y); } } - } - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onTick(ClientTickEvent event) { - if(event.phase == Phase.END) { + @PlayEvent + public void onTick(ZEndClientTick event) { Player player = Minecraft.getInstance().player; - + if(player != null) { Inventory inventory = player.getInventory(); if(currentHeldItem != -1 && inventory.selected != currentHeldItem) { inventory.selected = currentHeldItem; - currentHeldItem = -1; + currentHeldItem = -1; } } - } - - if(hotbarChangeOpen && height < MAX_HEIGHT) { - height += ANIM_PER_TICK; - animating = true; - } else if(!hotbarChangeOpen && height > 0) { - height -= ANIM_PER_TICK; - animating = true; - } else animating = false; - } - private float getRealHeight(float part) { - if(!animating) - return height; - return height + part * ANIM_PER_TICK * (hotbarChangeOpen ? 1 : -1); - } + if(hotbarChangeOpen && height < MAX_HEIGHT) { + height += ANIM_PER_TICK; + animating = true; + } else if(!hotbarChangeOpen && height > 0) { + height -= ANIM_PER_TICK; + animating = true; + } else animating = false; + } + + private void acceptInput(int currInput) { + Minecraft mc = Minecraft.getInstance(); + boolean down = changeHotbarKey.isDown(); + boolean wasDown = keyDown; + keyDown = down; + if(mc.isWindowActive()) { + if(down && !wasDown) + hotbarChangeOpen = !hotbarChangeOpen; + else if(hotbarChangeOpen) + for(int i = 0; i < 3; i++) + if(isKeyDownOrFallback(mc.options.keyHotbarSlots[i], 49 + i, currInput)) { + QuarkNetwork.sendToServer(new ChangeHotbarMessage(i + 1)); + hotbarChangeOpen = false; + currentHeldItem = mc.player.getInventory().selected; + return; + } + + } + } + private boolean isKeyDownOrFallback(KeyMapping key, int input, int currInput) { + if(key.isUnbound()) + return currInput != -1 && input == currInput; + + return key.isDown(); + } + + private float getRealHeight(float part) { + if(!animating) + return height; + return height + part * ANIM_PER_TICK * (hotbarChangeOpen ? 1 : -1); + } + } } diff --git a/src/main/java/vazkii/quark/content/management/module/InventorySortingModule.java b/src/main/java/vazkii/quark/content/management/module/InventorySortingModule.java index ac47615e61..6bf3100251 100644 --- a/src/main/java/vazkii/quark/content/management/module/InventorySortingModule.java +++ b/src/main/java/vazkii/quark/content/management/module/InventorySortingModule.java @@ -1,27 +1,23 @@ package vazkii.quark.content.management.module; -import java.util.function.BooleanSupplier; - import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.sounds.SimpleSoundInstance; import net.minecraft.sounds.SoundEvents; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.client.handler.InventoryButtonHandler; -import vazkii.quark.base.client.handler.InventoryButtonHandler.ButtonProvider; -import vazkii.quark.base.client.handler.InventoryButtonHandler.ButtonTargetType; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.SortInventoryMessage; import vazkii.quark.content.management.client.screen.widgets.MiniInventoryButton; -import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.client.event.ZKeyMapping; +import vazkii.zeta.event.bus.LoadEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "management") +import java.util.function.BooleanSupplier; + +@ZetaLoadModule(category = "management") public class InventorySortingModule extends ZetaModule { @Config @@ -33,56 +29,55 @@ public class InventorySortingModule extends ZetaModule { @Config(description = "Play a click when sorting inventories using keybindings") public static boolean satisfyingClick = true; - @LoadEvent - @OnlyIn(Dist.CLIENT) - public void registerKeybinds(ZKeyMapping event) { - KeyMapping sortPlayer = event.init("quark.keybind.sort_player", null, QuarkClient.INV_GROUP); + public static class Client extends InventorySortingModule { + @LoadEvent + public void registerKeybinds(ZKeyMapping event) { + KeyMapping sortPlayer = event.init("quark.keybind.sort_player", null, QuarkClient.INV_GROUP); - InventoryButtonHandler.addButtonProvider(this, ButtonTargetType.PLAYER_INVENTORY, 0, - sortPlayer, - (screen) -> { - if (enablePlayerInventory) { - if (satisfyingClick) - click(); - QuarkNetwork.sendToServer(new SortInventoryMessage(true)); - } - }, - provider("sort", true, () -> enablePlayerInventory), - () -> enablePlayerInventory); - - InventoryButtonHandler.addButtonProvider(this, ButtonTargetType.CONTAINER_PLAYER_INVENTORY, 0, - sortPlayer, - (screen) -> { - if (enablePlayerInventoryInChests) { - if (satisfyingClick) - click(); - QuarkNetwork.sendToServer(new SortInventoryMessage(true)); - } - }, - provider("sort_inventory", true, () -> enablePlayerInventoryInChests), - () -> enablePlayerInventoryInChests); - - InventoryButtonHandler.addButtonProvider(event, this, ButtonTargetType.CONTAINER_INVENTORY, 0, - "quark.keybind.sort_container", - (screen) -> { - if (enableChests) { - if (satisfyingClick) - click(); - QuarkNetwork.sendToServer(new SortInventoryMessage(false)); - } - }, - provider("sort_container", false, () -> enableChests), - () -> enableChests); - } + InventoryButtonHandler.addButtonProvider(this, InventoryButtonHandler.ButtonTargetType.PLAYER_INVENTORY, 0, + sortPlayer, + (screen) -> { + if (enablePlayerInventory) { + if (satisfyingClick) + click(); + QuarkNetwork.sendToServer(new SortInventoryMessage(true)); + } + }, + provider("sort", true, () -> enablePlayerInventory), + () -> enablePlayerInventory); - @OnlyIn(Dist.CLIENT) - private ButtonProvider provider(String tooltip, boolean forcePlayer, BooleanSupplier condition) { - return (parent, x, y) -> !condition.getAsBoolean() ? null : - new MiniInventoryButton(parent, 0, x, y, "quark.gui.button." + tooltip, (b) -> QuarkNetwork.sendToServer(new SortInventoryMessage(forcePlayer))); - } + InventoryButtonHandler.addButtonProvider(this, InventoryButtonHandler.ButtonTargetType.CONTAINER_PLAYER_INVENTORY, 0, + sortPlayer, + (screen) -> { + if (enablePlayerInventoryInChests) { + if (satisfyingClick) + click(); + QuarkNetwork.sendToServer(new SortInventoryMessage(true)); + } + }, + provider("sort_inventory", true, () -> enablePlayerInventoryInChests), + () -> enablePlayerInventoryInChests); + + InventoryButtonHandler.addButtonProvider(event, this, InventoryButtonHandler.ButtonTargetType.CONTAINER_INVENTORY, 0, + "quark.keybind.sort_container", + (screen) -> { + if (enableChests) { + if (satisfyingClick) + click(); + QuarkNetwork.sendToServer(new SortInventoryMessage(false)); + } + }, + provider("sort_container", false, () -> enableChests), + () -> enableChests); + } + + private InventoryButtonHandler.ButtonProvider provider(String tooltip, boolean forcePlayer, BooleanSupplier condition) { + return (parent, x, y) -> !condition.getAsBoolean() ? null : + new MiniInventoryButton(parent, 0, x, y, "quark.gui.button." + tooltip, (b) -> QuarkNetwork.sendToServer(new SortInventoryMessage(forcePlayer))); + } - @OnlyIn(Dist.CLIENT) - private void click() { - Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + private void click() { + Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + } } } diff --git a/src/main/java/vazkii/quark/content/management/module/ItemSharingModule.java b/src/main/java/vazkii/quark/content/management/module/ItemSharingModule.java index 5c751ad603..f67e846410 100755 --- a/src/main/java/vazkii/quark/content/management/module/ItemSharingModule.java +++ b/src/main/java/vazkii/quark/content/management/module/ItemSharingModule.java @@ -10,7 +10,7 @@ */ package vazkii.quark.content.management.module; -import com.mojang.blaze3d.platform.InputConstants.Type; +import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.SharedConstants; @@ -27,26 +27,23 @@ import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.event.ScreenEvent.KeyPressed; -import net.minecraftforge.client.event.ScreenEvent.MouseButtonPressed; -import net.minecraftforge.eventbus.api.SubscribeEvent; import org.lwjgl.glfw.GLFW; -import vazkii.quark.base.module.LoadModule; import vazkii.quark.base.module.ModuleLoader; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.network.QuarkNetwork; import vazkii.quark.base.network.message.ShareItemMessage; import vazkii.quark.mixin.accessor.AccessorServerGamePacketListenerImpl; import vazkii.quark.mixin.client.accessor.AccessorLocalPlayer; +import vazkii.zeta.client.event.ZScreen; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; import java.time.Instant; import java.util.List; -@LoadModule(category = "management", hasSubscriptions = true, subscribeOn = Dist.CLIENT) +@ZetaLoadModule(category = "management") public class ItemSharingModule extends ZetaModule { @Config @@ -55,51 +52,10 @@ public class ItemSharingModule extends ZetaModule { //global variable to apply 5 sec cooldown private static long lastShareTimestamp = -1; - @OnlyIn(Dist.CLIENT) - public static void renderItemForMessage(PoseStack poseStack, FormattedCharSequence sequence, float x, float y, int color) { - if (!ModuleLoader.INSTANCE.isModuleEnabled(ItemSharingModule.class) || !renderItemsInChat) - return; - - Minecraft mc = Minecraft.getInstance(); - - StringBuilder before = new StringBuilder(); - - int halfSpace = mc.font.width(" ") / 2; - - sequence.accept((counter_, style, character) -> { - String sofar = before.toString(); - if (sofar.endsWith(" ")) { - render(mc, poseStack, sofar.substring(0, sofar.length() - 2), character == ' ' ? 0 : -halfSpace, x, y, style, color); - return false; - } - before.append((char) character); - return true; - }); - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onKeyInput(KeyPressed.Pre event) { - KeyMapping key = getChatKey(); - if(key.getKey().getType() == Type.KEYSYM && event.getKeyCode() == key.getKey().getValue()) - event.setCanceled(clicc()); - - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void onMouseInput(MouseButtonPressed.Post event) { - KeyMapping key = getChatKey(); - int btn = event.getButton(); - if(key.getKey().getType() == Type.MOUSE && btn != GLFW.GLFW_MOUSE_BUTTON_LEFT && btn == key.getKey().getValue()) - event.setCanceled(clicc()); - } - - private KeyMapping getChatKey() { - return Minecraft.getInstance().options.keyChat; - } + // used in a mixin because rendering overrides are cursed by necessity hahayes + public static float alphaValue = 1F; - public boolean clicc() { + public boolean click() { Minecraft mc = Minecraft.getInstance(); Screen screen = mc.screen; @@ -174,43 +130,82 @@ public static MutableComponent createStackComponent(ItemStack stack, MutableComp return out.append(component); } - @OnlyIn(Dist.CLIENT) - private static void render(Minecraft mc, PoseStack pose, String before, float extraShift, float x, float y, Style style, int color) { - float a = (color >> 24 & 255) / 255.0F; + @ZetaLoadModule(clientReplacement = true) + public static class Client extends ItemSharingModule { + public static void renderItemForMessage(PoseStack poseStack, FormattedCharSequence sequence, float x, float y, int color) { + if (!ModuleLoader.INSTANCE.isModuleEnabled(ItemSharingModule.class) || !renderItemsInChat) + return; - HoverEvent hoverEvent = style.getHoverEvent(); - if (hoverEvent != null && hoverEvent.getAction() == HoverEvent.Action.SHOW_ITEM) { - HoverEvent.ItemStackInfo contents = hoverEvent.getValue(HoverEvent.Action.SHOW_ITEM); + Minecraft mc = Minecraft.getInstance(); - ItemStack stack = contents != null ? contents.getItemStack() : ItemStack.EMPTY; + StringBuilder before = new StringBuilder(); - if (stack.isEmpty()) - stack = new ItemStack(Blocks.BARRIER); // for invalid icon + int halfSpace = mc.font.width(" ") / 2; - float shift = mc.font.width(before) + extraShift; + sequence.accept((counter_, style, character) -> { + String sofar = before.toString(); + if (sofar.endsWith(" ")) { + render(mc, poseStack, sofar.substring(0, sofar.length() - 2), character == ' ' ? 0 : -halfSpace, x, y, style, color); + return false; + } + before.append((char) character); + return true; + }); + } + + @PlayEvent + public void onKeyInput(ZScreen.KeyPressed.Pre event) { + KeyMapping key = getChatKey(); + if(key.getKey().getType() == InputConstants.Type.KEYSYM && event.getKeyCode() == key.getKey().getValue()) + event.setCanceled(click()); + + } + + @PlayEvent + public void onMouseInput(ZScreen.MouseButtonPressed.Post event) { + KeyMapping key = getChatKey(); + int btn = event.getButton(); + if(key.getKey().getType() == InputConstants.Type.MOUSE && btn != GLFW.GLFW_MOUSE_BUTTON_LEFT && btn == key.getKey().getValue()) + event.setCanceled(click()); + } + + private static void render(Minecraft mc, PoseStack pose, String before, float extraShift, float x, float y, Style style, int color) { + float a = (color >> 24 & 255) / 255.0F; + + HoverEvent hoverEvent = style.getHoverEvent(); + if (hoverEvent != null && hoverEvent.getAction() == HoverEvent.Action.SHOW_ITEM) { + HoverEvent.ItemStackInfo contents = hoverEvent.getValue(HoverEvent.Action.SHOW_ITEM); + + ItemStack stack = contents != null ? contents.getItemStack() : ItemStack.EMPTY; - if (a > 0) { - alphaValue = a; + if (stack.isEmpty()) + stack = new ItemStack(Blocks.BARRIER); // for invalid icon - PoseStack poseStack = RenderSystem.getModelViewStack(); + float shift = mc.font.width(before) + extraShift; - poseStack.pushPose(); + if (a > 0) { + alphaValue = a; - poseStack.mulPoseMatrix(pose.last().pose()); + PoseStack poseStack = RenderSystem.getModelViewStack(); - poseStack.translate(shift + x, y, 0); - poseStack.scale(0.5f, 0.5f, 0.5f); - mc.getItemRenderer().renderGuiItem(stack, 0, 0); - poseStack.popPose(); + poseStack.pushPose(); - RenderSystem.applyModelViewMatrix(); + poseStack.mulPoseMatrix(pose.last().pose()); - alphaValue = 1F; + poseStack.translate(shift + x, y, 0); + poseStack.scale(0.5f, 0.5f, 0.5f); + mc.getItemRenderer().renderGuiItem(stack, 0, 0); + poseStack.popPose(); + + RenderSystem.applyModelViewMatrix(); + + alphaValue = 1F; + } } } - } - - // used in a mixin because rendering overrides are cursed by necessity hahayes - public static float alphaValue = 1F; + private KeyMapping getChatKey() { + return Minecraft.getInstance().options.keyChat; + } + } } diff --git a/src/main/java/vazkii/quark/content/management/module/QuickArmorSwappingModule.java b/src/main/java/vazkii/quark/content/management/module/QuickArmorSwappingModule.java index 18f2d7eb9d..d7efea5dd4 100644 --- a/src/main/java/vazkii/quark/content/management/module/QuickArmorSwappingModule.java +++ b/src/main/java/vazkii/quark/content/management/module/QuickArmorSwappingModule.java @@ -7,19 +7,19 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; +import vazkii.zeta.event.ZPlayerInteract; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; -@LoadModule(category = "management", hasSubscriptions = true) +@ZetaLoadModule(category = "management") public class QuickArmorSwappingModule extends ZetaModule { @Config public static boolean swapOffHand = true; - @SubscribeEvent - public void onEntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific event) { + @PlayEvent + public void onEntityInteractSpecific(ZPlayerInteract.EntityInteractSpecific event) { Player player = event.getEntity(); if(player.isSpectator() || player.getAbilities().instabuild || !(event.getTarget() instanceof ArmorStand armorStand)) diff --git a/src/main/java/vazkii/quark/content/mobs/module/CrabsModule.java b/src/main/java/vazkii/quark/content/mobs/module/CrabsModule.java index 13d7ef7fb9..78c904d425 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/CrabsModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/CrabsModule.java @@ -30,26 +30,26 @@ import vazkii.quark.base.handler.advancement.mod.TwoByTwoModifier; import vazkii.quark.base.item.QuarkItem; import vazkii.quark.base.item.QuarkMobBucketItem; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.EntitySpawnConfig; -import vazkii.zeta.util.Hint; import vazkii.quark.base.util.QuarkEffect; import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.CrabRenderer; import vazkii.quark.content.mobs.entity.Crab; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; /** * @author WireSegal * Created at 7:28 PM on 9/22/19. */ -@LoadModule(category = "mobs", hasSubscriptions = true) +@ZetaLoadModule(category = "mobs") public class CrabsModule extends ZetaModule { public static EntityType crabType; diff --git a/src/main/java/vazkii/quark/content/mobs/module/ForgottenModule.java b/src/main/java/vazkii/quark/content/mobs/module/ForgottenModule.java index fe5c2be5bc..7366511bfa 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/ForgottenModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/ForgottenModule.java @@ -1,14 +1,9 @@ package vazkii.quark.content.mobs.module; import com.google.common.collect.ImmutableSet; - import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.core.Registry; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.MobCategory; -import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.*; import net.minecraft.world.item.Item; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.phys.Vec3; @@ -16,25 +11,26 @@ import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; import net.minecraftforge.eventbus.api.Event.Result; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.EntityAttributeHandler; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.mod.MonsterHunterModifier; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; -import vazkii.zeta.util.Hint; import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.ForgottenRenderer; import vazkii.quark.content.mobs.entity.Forgotten; import vazkii.quark.content.mobs.item.ForgottenHatItem; +import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.ZLivingSpawn; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.event.bus.ZResult; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "mobs", hasSubscriptions = true) +@ZetaLoadModule(category = "mobs") public class ForgottenModule extends ZetaModule { public static EntityType forgottenType; @@ -69,17 +65,17 @@ public final void clientSetup(ZClientSetup event) { EntityRenderers.register(forgottenType, ForgottenRenderer::new); } - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onSkeletonSpawn(LivingSpawnEvent.CheckSpawn event) { + @PlayEvent + public void onSkeletonSpawn(ZLivingSpawn.CheckSpawn.Lowest event) { if (event.getSpawnReason() == MobSpawnType.SPAWNER) return; LivingEntity entity = event.getEntity(); - Result result = event.getResult(); + ZResult result = event.getResult(); LevelAccessor world = event.getLevel(); - if(entity.getType() == EntityType.SKELETON && entity instanceof Mob mob && result != Result.DENY && entity.getY() < maxHeightForSpawn && world.getRandom().nextDouble() < forgottenSpawnRate) { - if(result == Result.ALLOW || (mob.checkSpawnRules(world, event.getSpawnReason()) && mob.checkSpawnObstruction(world))) { + if (entity.getType() == EntityType.SKELETON && entity instanceof Mob mob && result != ZResult.DENY && entity.getY() < maxHeightForSpawn && world.getRandom().nextDouble() < forgottenSpawnRate) { + if(result == ZResult.ALLOW || (mob.checkSpawnRules(world, event.getSpawnReason()) && mob.checkSpawnObstruction(world))) { Forgotten forgotten = new Forgotten(forgottenType, entity.level); Vec3 epos = entity.position(); @@ -91,7 +87,7 @@ public void onSkeletonSpawn(LivingSpawnEvent.CheckSpawn event) { if(newEvent.getResult() != Result.DENY) { world.addFreshEntity(forgotten); - event.setResult(Result.DENY); + event.setResult(ZResult.DENY); } } } diff --git a/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java b/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java index e9b476c4bb..0e97087f85 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java @@ -1,9 +1,6 @@ package vazkii.quark.content.mobs.module; -import static net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET; - import com.google.common.collect.ImmutableSet; - import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; @@ -17,18 +14,12 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.Heightmap; -import net.minecraftforge.event.entity.living.LivingChangeTargetEvent; -import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; -import net.minecraftforge.eventbus.api.Event.Result; -import net.minecraftforge.eventbus.api.SubscribeEvent; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.EntityAttributeHandler; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; import vazkii.quark.base.handler.advancement.mod.MonsterHunterModifier; import vazkii.quark.base.handler.advancement.mod.TwoByTwoModifier; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.CostSensitiveEntitySpawnConfig; @@ -36,16 +27,24 @@ import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.FoxhoundRenderer; import vazkii.quark.content.mobs.entity.Foxhound; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZCommonSetup; +import vazkii.zeta.event.ZLivingChangeTarget; import vazkii.zeta.event.ZRegister; +import vazkii.zeta.event.ZSleepingLocationCheck; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.event.bus.PlayEvent; +import vazkii.zeta.event.bus.ZResult; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import static net.minecraftforge.event.entity.living.LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET; /** * @author WireSegal * Created at 5:00 PM on 9/26/19. */ -@LoadModule(category = "mobs", hasSubscriptions = true) +@ZetaLoadModule(category = "mobs") public class FoxhoundModule extends ZetaModule { public static EntityType foxhoundType; @@ -99,8 +98,8 @@ public final void clientSetup(ZClientSetup event) { EntityRenderers.register(foxhoundType, FoxhoundRenderer::new); } - @SubscribeEvent - public void onAggro(LivingChangeTargetEvent event) { + @PlayEvent + public void onAggro(ZLivingChangeTarget event) { if (event.getNewTarget() != null && event.getTargetType() != BEHAVIOR_TARGET && event.getEntity().getType() == EntityType.IRON_GOLEM @@ -109,15 +108,15 @@ public void onAggro(LivingChangeTargetEvent event) { event.setCanceled(true); } - @SubscribeEvent - public void onSleepCheck(SleepingLocationCheckEvent event) { + @PlayEvent + public void onSleepCheck(ZSleepingLocationCheck event) { if(event.getEntity() instanceof Foxhound) { BlockPos pos = event.getSleepingLocation(); Level world = event.getEntity().level; boolean sleep = world.getBlockState(pos.below()).getLightEmission(world, pos.below()) > 2; if(sleep) - event.setResult(Result.ALLOW); + event.setResult(ZResult.ALLOW); } } } diff --git a/src/main/java/vazkii/quark/content/mobs/module/ShibaModule.java b/src/main/java/vazkii/quark/content/mobs/module/ShibaModule.java index 839f526f49..5997b53dbb 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/ShibaModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/ShibaModule.java @@ -17,20 +17,20 @@ import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; import vazkii.quark.base.handler.advancement.mod.TwoByTwoModifier; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.EntitySpawnConfig; -import vazkii.zeta.util.Hint; import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.ShibaRenderer; import vazkii.quark.content.mobs.entity.Shiba; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "mobs") +@ZetaLoadModule(category = "mobs") public class ShibaModule extends ZetaModule { public static EntityType shibaType; diff --git a/src/main/java/vazkii/quark/content/mobs/module/StonelingsModule.java b/src/main/java/vazkii/quark/content/mobs/module/StonelingsModule.java index 5f68548f15..945be959bd 100755 --- a/src/main/java/vazkii/quark/content/mobs/module/StonelingsModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/StonelingsModule.java @@ -14,23 +14,23 @@ import vazkii.quark.base.handler.EntityAttributeHandler; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.DimensionConfig; import vazkii.quark.base.module.config.type.EntitySpawnConfig; -import vazkii.zeta.util.Hint; import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.StonelingRenderer; import vazkii.quark.content.mobs.entity.Stoneling; import vazkii.quark.content.mobs.item.DiamondHeartItem; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; -@LoadModule(category = "mobs", hasSubscriptions = true) +@ZetaLoadModule(category = "mobs") public class StonelingsModule extends ZetaModule { public static EntityType stonelingType; diff --git a/src/main/java/vazkii/quark/content/mobs/module/ToretoiseModule.java b/src/main/java/vazkii/quark/content/mobs/module/ToretoiseModule.java index 3543c1d709..66e3a190bf 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/ToretoiseModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/ToretoiseModule.java @@ -1,9 +1,6 @@ package vazkii.quark.content.mobs.module; -import java.util.List; - import com.google.common.collect.Lists; - import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.core.Registry; import net.minecraft.tags.BiomeTags; @@ -16,8 +13,6 @@ import vazkii.quark.base.handler.EntityAttributeHandler; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.QuarkGenericTrigger; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.DimensionConfig; @@ -25,11 +20,15 @@ import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.ToretoiseRenderer; import vazkii.quark.content.mobs.entity.Toretoise; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; + +import java.util.List; -@LoadModule(category = "mobs", hasSubscriptions = true) +@ZetaLoadModule(category = "mobs") public class ToretoiseModule extends ZetaModule { public static EntityType toretoiseType; diff --git a/src/main/java/vazkii/quark/content/mobs/module/WraithModule.java b/src/main/java/vazkii/quark/content/mobs/module/WraithModule.java index 314fd65c7b..92213ef7e1 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/WraithModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/WraithModule.java @@ -1,11 +1,7 @@ package vazkii.quark.content.mobs.module; -import java.util.List; -import java.util.stream.Collectors; - import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; - import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; @@ -23,26 +19,29 @@ import vazkii.quark.base.handler.EntityAttributeHandler; import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler; import vazkii.quark.base.handler.advancement.mod.MonsterHunterModifier; -import vazkii.quark.base.module.LoadModule; -import vazkii.zeta.module.ZetaModule; import vazkii.quark.base.module.config.Config; import vazkii.quark.base.module.config.type.CompoundBiomeConfig; import vazkii.quark.base.module.config.type.CostSensitiveEntitySpawnConfig; import vazkii.quark.base.module.config.type.EntitySpawnConfig; -import vazkii.zeta.util.Hint; import vazkii.quark.base.world.EntitySpawnHandler; import vazkii.quark.content.mobs.client.render.entity.SoulBeadRenderer; import vazkii.quark.content.mobs.client.render.entity.WraithRenderer; import vazkii.quark.content.mobs.entity.SoulBead; import vazkii.quark.content.mobs.entity.Wraith; import vazkii.quark.content.mobs.item.SoulBeadItem; +import vazkii.zeta.client.event.ZClientSetup; import vazkii.zeta.event.ZCommonSetup; import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; -import vazkii.zeta.client.event.ZClientSetup; +import vazkii.zeta.module.ZetaLoadModule; +import vazkii.zeta.module.ZetaModule; +import vazkii.zeta.util.Hint; + +import java.util.List; +import java.util.stream.Collectors; -@LoadModule(category = "mobs") +@ZetaLoadModule(category = "mobs") public class WraithModule extends ZetaModule { public static EntityType wraithType; diff --git a/src/main/java/vazkii/quark/content/tools/module/AbacusModule.java b/src/main/java/vazkii/quark/content/tools/module/AbacusModule.java index d57c858e4a..5deaf5ec69 100644 --- a/src/main/java/vazkii/quark/content/tools/module/AbacusModule.java +++ b/src/main/java/vazkii/quark/content/tools/module/AbacusModule.java @@ -27,7 +27,7 @@ import vazkii.quark.base.module.config.type.inputtable.RGBAColorConfig; import vazkii.zeta.util.Hint; import vazkii.quark.content.tools.item.AbacusItem; -import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderGuiOverlay; import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; @@ -57,7 +57,7 @@ public void clientSetup(ZClientSetup e) { } @PlayEvent - public void onHUDRender(ZRenderOverlay.Crosshair event) { + public void onHUDRender(ZRenderGuiOverlay.Crosshair event) { Minecraft mc = Minecraft.getInstance(); Player player = mc.player; if(player != null) { 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 6e1efd0a35..de12351028 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/AutomaticRecipeUnlockModule.java @@ -18,15 +18,15 @@ import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.level.GameRules; import vazkii.quark.base.Quark; +import vazkii.quark.base.module.config.Config; import vazkii.zeta.client.event.ZEndClientTick; -import vazkii.zeta.client.event.ZScreenInit; +import vazkii.zeta.client.event.ZScreen; +import vazkii.zeta.event.ZConfigChanged; import vazkii.zeta.event.ZPlayerLoggedIn; +import vazkii.zeta.event.bus.LoadEvent; 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; -import vazkii.zeta.event.bus.LoadEvent; import java.util.*; @@ -103,7 +103,7 @@ public static void removeRecipeAdvancements(Map> descriptorSorting = new TreeMap<>(); @@ -244,7 +227,7 @@ public void initGui(ZScreenInit.Post event) { } @PlayEvent - public void onKeyInput(ZInputEvent.Key event) { + public void onKeyInput(ZInput.Key event) { Minecraft mc = Minecraft.getInstance(); if(mc.isWindowActive()) { for(KeyMapping key : Client.emoteKeybinds.keySet()) { @@ -258,7 +241,7 @@ public void onKeyInput(ZInputEvent.Key event) { } @PlayEvent - public void drawCrosshair(ZRenderOverlay.Crosshair event) { + public void drawCrosshair(ZRenderGuiOverlay.Crosshair event) { Minecraft mc = Minecraft.getInstance(); Window res = event.getWindow(); PoseStack stack = event.getPoseStack(); diff --git a/src/main/java/vazkii/quark/content/tweaks/module/ReacharoundPlacingModule.java b/src/main/java/vazkii/quark/content/tweaks/module/ReacharoundPlacingModule.java index 5ce56cefe6..9f3e7e5624 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/ReacharoundPlacingModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/ReacharoundPlacingModule.java @@ -32,7 +32,7 @@ import vazkii.quark.base.Quark; import vazkii.quark.base.handler.RayTraceHandler; import vazkii.zeta.client.event.ZEndClientTick; -import vazkii.zeta.client.event.ZRenderOverlay; +import vazkii.zeta.client.event.ZRenderGuiOverlay; import vazkii.zeta.event.ZRightClickItem; import vazkii.zeta.event.bus.PlayEvent; import vazkii.zeta.module.ZetaLoadModule; @@ -189,7 +189,7 @@ protected record ReacharoundTarget(BlockPos pos, Direction dir, InteractionHand public static class Client extends ReacharoundPlacingModule { @PlayEvent - public void onRender(ZRenderOverlay.Crosshair event) { + public void onRender(ZRenderGuiOverlay.Crosshair event) { Minecraft mc = Minecraft.getInstance(); Player player = mc.player; diff --git a/src/main/java/vazkii/quark/mixin/client/ChatComponentMixin.java b/src/main/java/vazkii/quark/mixin/client/ChatComponentMixin.java index 0bcc9ea786..69848c9730 100644 --- a/src/main/java/vazkii/quark/mixin/client/ChatComponentMixin.java +++ b/src/main/java/vazkii/quark/mixin/client/ChatComponentMixin.java @@ -16,7 +16,7 @@ public class ChatComponentMixin { @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Font;drawShadow(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/util/FormattedCharSequence;FFI)I")) private int drawItems(Font instance, PoseStack poseStack, FormattedCharSequence sequence, float x, float y, int color, Operation original) { - ItemSharingModule.renderItemForMessage(poseStack, sequence, x, y, color); + ItemSharingModule.Client.renderItemForMessage(poseStack, sequence, x, y, color); return original.call(instance, poseStack, sequence, x, y, color); } diff --git a/src/main/java/vazkii/quark/mixin/client/ContainerScreenMixin.java b/src/main/java/vazkii/quark/mixin/client/ContainerScreenMixin.java index 40439e0456..23a1cdc83a 100644 --- a/src/main/java/vazkii/quark/mixin/client/ContainerScreenMixin.java +++ b/src/main/java/vazkii/quark/mixin/client/ContainerScreenMixin.java @@ -14,14 +14,14 @@ public class ContainerScreenMixin { at = @At("STORE"), index = 15) private boolean hasShiftDownClick(boolean curr) { - return EasyTransferingModule.hasShiftDown(curr); + return EasyTransferingModule.Client.hasShiftDown(curr); } @ModifyVariable(method = "mouseReleased(DDI)Z", at = @At("STORE"), index = 12) private boolean hasShiftDownRelease(boolean curr) { - return EasyTransferingModule.hasShiftDown(curr); + return EasyTransferingModule.Client.hasShiftDown(curr); } } diff --git a/src/main/java/vazkii/quark/mixin/client/ScreenMixin.java b/src/main/java/vazkii/quark/mixin/client/ScreenMixin.java index 5991e03895..56c3205ce8 100644 --- a/src/main/java/vazkii/quark/mixin/client/ScreenMixin.java +++ b/src/main/java/vazkii/quark/mixin/client/ScreenMixin.java @@ -11,6 +11,6 @@ public class ScreenMixin { @ModifyReturnValue(method = "hasShiftDown", at = @At("RETURN")) private static boolean hasShiftDown(boolean prev) { - return EasyTransferingModule.hasShiftDown(prev); + return EasyTransferingModule.Client.hasShiftDown(prev); } } diff --git a/src/main/java/vazkii/zeta/client/event/ZInput.java b/src/main/java/vazkii/zeta/client/event/ZInput.java new file mode 100644 index 0000000000..b21cab30c9 --- /dev/null +++ b/src/main/java/vazkii/zeta/client/event/ZInput.java @@ -0,0 +1,15 @@ +package vazkii.zeta.client.event; + +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZInput extends IZetaPlayEvent { + interface MouseButton extends ZInput { + int getButton(); + } + + interface Key extends ZInput { + int getKey(); + int getScanCode(); + int getAction(); + } +} diff --git a/src/main/java/vazkii/zeta/client/event/ZRenderGuiOverlay.java b/src/main/java/vazkii/zeta/client/event/ZRenderGuiOverlay.java new file mode 100644 index 0000000000..fa9c021751 --- /dev/null +++ b/src/main/java/vazkii/zeta/client/event/ZRenderGuiOverlay.java @@ -0,0 +1,49 @@ +package vazkii.zeta.client.event; + +import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.vertex.PoseStack; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZRenderGuiOverlay extends IZetaPlayEvent { + Window getWindow(); + PoseStack getPoseStack(); + float getPartialTick(); + + boolean shouldDrawSurvivalElements(); + int getLeftHeight(); //weird ForgeGui stuff + + interface Hotbar extends ZRenderGuiOverlay { + interface Pre extends Hotbar { } + interface Post extends Hotbar { } + } + + interface Crosshair extends ZRenderGuiOverlay { + interface Pre extends Crosshair { } + interface Post extends Crosshair { } + } + + interface PlayerHealth extends ZRenderGuiOverlay { + interface Pre extends PlayerHealth { } + interface Post extends PlayerHealth { } + } + + interface ArmorLevel extends ZRenderGuiOverlay { + interface Pre extends ArmorLevel { } + interface Post extends ArmorLevel { } + } + + interface DebugText extends ZRenderGuiOverlay { + interface Pre extends DebugText { } + interface Post extends DebugText { } + } + + interface PotionIcons extends ZRenderGuiOverlay { + interface Pre extends PotionIcons { } + interface Post extends PotionIcons { } + } + + interface ChatPanel extends ZRenderGuiOverlay { + interface Pre extends ChatPanel { } + interface Post extends ChatPanel { } + } +} diff --git a/src/main/java/vazkii/zeta/client/event/ZRenderOverlay.java b/src/main/java/vazkii/zeta/client/event/ZRenderOverlay.java deleted file mode 100644 index 00228587ce..0000000000 --- a/src/main/java/vazkii/zeta/client/event/ZRenderOverlay.java +++ /dev/null @@ -1,28 +0,0 @@ -package vazkii.zeta.client.event; - -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZRenderOverlay extends IZetaPlayEvent { - Window getWindow(); - PoseStack getPoseStack(); - float getPartialTick(); - - boolean shouldDrawSurvivalElements(); - int getLeftHeight(); //weird ForgeGui stuff - - interface ArmorLevel extends ZRenderOverlay { - interface Pre extends Chat { } - interface Post extends Chat { } - } - interface Chat extends ZRenderOverlay { - interface Pre extends Chat { } - interface Post extends Chat { } - } - interface Crosshair extends ZRenderOverlay { } - interface Hotbar extends ZRenderOverlay { - interface Pre extends Chat { } - interface Post extends Chat { } - } -} diff --git a/src/main/java/vazkii/zeta/client/event/ZRenderTooltip.java b/src/main/java/vazkii/zeta/client/event/ZRenderTooltip.java new file mode 100644 index 0000000000..8dd3a5078e --- /dev/null +++ b/src/main/java/vazkii/zeta/client/event/ZRenderTooltip.java @@ -0,0 +1,18 @@ +package vazkii.zeta.client.event; + +import com.mojang.datafixers.util.Either; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +import java.util.List; + +public interface ZRenderTooltip extends IZetaPlayEvent { + interface GatherComponents extends IZetaPlayEvent, ZRenderTooltip { + ItemStack getItemStack(); + List> getTooltipElements(); + + interface Low extends GatherComponents { } + } +} diff --git a/src/main/java/vazkii/zeta/client/event/ZScreen.java b/src/main/java/vazkii/zeta/client/event/ZScreen.java new file mode 100644 index 0000000000..e78e7583fd --- /dev/null +++ b/src/main/java/vazkii/zeta/client/event/ZScreen.java @@ -0,0 +1,64 @@ +package vazkii.zeta.client.event; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import vazkii.zeta.event.bus.Cancellable; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +import java.util.List; + +public interface ZScreen extends IZetaPlayEvent { + Screen getScreen(); + + interface Init extends ZScreen { + List getListenersList(); + void addListener(GuiEventListener listener); + void removeListener(GuiEventListener listener); + + interface Pre extends Init { } + interface Post extends Init { } + } + + interface Render extends ZScreen { + PoseStack getPoseStack(); + int getMouseX(); + int getMouseY(); + + interface Pre extends Render { } + interface Post extends Render { } + } + + interface MouseButtonPressed extends ZScreen, Cancellable { + int getButton(); + double getMouseX(); + double getMouseY(); + + interface Pre extends MouseButtonPressed { } + interface Post extends MouseButtonPressed { } + } + + interface MouseScrolled extends ZScreen, Cancellable { + double getScrollDelta(); + + interface Pre extends MouseScrolled { } + interface Post extends MouseScrolled { } + } + + interface KeyPressed extends ZScreen, Cancellable { + int getKeyCode(); + int getScanCode(); + int getModifiers(); + + interface Pre extends KeyPressed { } + interface Post extends KeyPressed { } + } + + interface CharacterTyped extends ZScreen, Cancellable { + char getCodePoint(); + int getModifiers(); + + interface Pre extends CharacterTyped { } + interface Post extends CharacterTyped { } + } +} diff --git a/src/main/java/vazkii/zeta/client/event/ZScreenCharacterTyped.java b/src/main/java/vazkii/zeta/client/event/ZScreenCharacterTyped.java deleted file mode 100644 index 847c98360c..0000000000 --- a/src/main/java/vazkii/zeta/client/event/ZScreenCharacterTyped.java +++ /dev/null @@ -1,14 +0,0 @@ -package vazkii.zeta.client.event; - -import net.minecraft.client.gui.screens.Screen; -import vazkii.zeta.event.bus.Cancellable; -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZScreenCharacterTyped extends IZetaPlayEvent, Cancellable { - Screen getScreen(); - char getCodePoint(); - int getModifiers(); - - interface Pre extends ZScreenCharacterTyped { } - interface Post extends ZScreenCharacterTyped { } -} diff --git a/src/main/java/vazkii/zeta/client/event/ZScreenInit.java b/src/main/java/vazkii/zeta/client/event/ZScreenInit.java deleted file mode 100644 index 3f5065f815..0000000000 --- a/src/main/java/vazkii/zeta/client/event/ZScreenInit.java +++ /dev/null @@ -1,17 +0,0 @@ -package vazkii.zeta.client.event; - -import java.util.List; - -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.screens.Screen; -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZScreenInit extends IZetaPlayEvent { - Screen getScreen(); - List getListenersList(); - void addListener(GuiEventListener listener); - void removeListener(GuiEventListener listener); - - interface Pre extends ZScreenInit { } - interface Post extends ZScreenInit { } -} diff --git a/src/main/java/vazkii/zeta/client/event/ZScreenKeyPressed.java b/src/main/java/vazkii/zeta/client/event/ZScreenKeyPressed.java deleted file mode 100644 index 21ed62e246..0000000000 --- a/src/main/java/vazkii/zeta/client/event/ZScreenKeyPressed.java +++ /dev/null @@ -1,15 +0,0 @@ -package vazkii.zeta.client.event; - -import net.minecraft.client.gui.screens.Screen; -import vazkii.zeta.event.bus.Cancellable; -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZScreenKeyPressed extends IZetaPlayEvent, Cancellable { - Screen getScreen(); - int getKeyCode(); - int getScanCode(); - int getModifiers(); - - interface Pre extends ZScreenKeyPressed { } - interface Post extends ZScreenKeyPressed { } -} diff --git a/src/main/java/vazkii/zeta/client/event/ZScreenMousePressed.java b/src/main/java/vazkii/zeta/client/event/ZScreenMousePressed.java deleted file mode 100644 index fcc5b0d48f..0000000000 --- a/src/main/java/vazkii/zeta/client/event/ZScreenMousePressed.java +++ /dev/null @@ -1,15 +0,0 @@ -package vazkii.zeta.client.event; - -import net.minecraft.client.gui.screens.Screen; -import vazkii.zeta.event.bus.Cancellable; -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZScreenMousePressed extends IZetaPlayEvent, Cancellable { - Screen getScreen(); - int getButton(); - double getMouseX(); - double getMouseY(); - - interface Pre extends ZScreenMousePressed { } - interface Post extends ZScreenMousePressed { } -} diff --git a/src/main/java/vazkii/zeta/event/ZAnvilUpdate.java b/src/main/java/vazkii/zeta/event/ZAnvilUpdate.java index 5e6493a904..990d94b48c 100644 --- a/src/main/java/vazkii/zeta/event/ZAnvilUpdate.java +++ b/src/main/java/vazkii/zeta/event/ZAnvilUpdate.java @@ -10,5 +10,5 @@ public interface ZAnvilUpdate extends IZetaPlayEvent { void setOutput(ItemStack output); void setCost(int cost); - interface Lowest extends IZetaPlayEvent, ZAnvilUpdate { } + interface Lowest extends ZAnvilUpdate { } } diff --git a/src/main/java/vazkii/zeta/event/ZAttachCapabilities.java b/src/main/java/vazkii/zeta/event/ZAttachCapabilities.java new file mode 100644 index 0000000000..59b6df7ea4 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZAttachCapabilities.java @@ -0,0 +1,10 @@ +package vazkii.zeta.event; + +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZAttachCapabilities extends IZetaPlayEvent { + T getObject(); + void addCapability(ResourceLocation key, ICapabilityProvider cap); +} diff --git a/src/main/java/vazkii/zeta/event/ZBabyEntitySpawn.java b/src/main/java/vazkii/zeta/event/ZBabyEntitySpawn.java new file mode 100644 index 0000000000..a9effc3433 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZBabyEntitySpawn.java @@ -0,0 +1,12 @@ +package vazkii.zeta.event; + +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Player; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZBabyEntitySpawn extends IZetaPlayEvent { + Mob getParentA(); + Player getCausedByPlayer(); + + interface Lowest extends ZBabyEntitySpawn { } +} diff --git a/src/main/java/vazkii/zeta/event/ZEntityJoinLevel.java b/src/main/java/vazkii/zeta/event/ZEntityJoinLevel.java new file mode 100644 index 0000000000..87d76b9bba --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZEntityJoinLevel.java @@ -0,0 +1,9 @@ +package vazkii.zeta.event; + +import net.minecraft.world.entity.Entity; +import vazkii.zeta.event.bus.Cancellable; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZEntityJoinLevel extends IZetaPlayEvent, Cancellable { + Entity getEntity(); +} diff --git a/src/main/java/vazkii/zeta/event/ZInputEvent.java b/src/main/java/vazkii/zeta/event/ZInputEvent.java deleted file mode 100644 index 3fa6605a59..0000000000 --- a/src/main/java/vazkii/zeta/event/ZInputEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package vazkii.zeta.event; - -import vazkii.zeta.event.bus.IZetaPlayEvent; - -public interface ZInputEvent extends IZetaPlayEvent { - interface MouseButton extends IZetaPlayEvent, ZInputEvent { - int getButton(); - } - - interface Key extends IZetaPlayEvent, ZInputEvent { - int getKey(); - int getScanCode(); - int getAction(); - } -} diff --git a/src/main/java/vazkii/zeta/event/ZLevelTick.java b/src/main/java/vazkii/zeta/event/ZLevelTick.java new file mode 100644 index 0000000000..5e62822e0f --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZLevelTick.java @@ -0,0 +1,11 @@ +package vazkii.zeta.event; + +import net.minecraft.world.level.Level; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZLevelTick extends IZetaPlayEvent { + Level getLevel(); + + interface Start extends ZLevelTick { } + interface End extends ZLevelTick { } +} diff --git a/src/main/java/vazkii/zeta/event/ZLivingChangeTarget.java b/src/main/java/vazkii/zeta/event/ZLivingChangeTarget.java new file mode 100644 index 0000000000..4f15d14867 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZLivingChangeTarget.java @@ -0,0 +1,12 @@ +package vazkii.zeta.event; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraftforge.event.entity.living.LivingChangeTargetEvent; +import vazkii.zeta.event.bus.Cancellable; +import vazkii.zeta.event.bus.IZetaPlayEvent; +import vazkii.zeta.event.bus.Living; + +public interface ZLivingChangeTarget extends IZetaPlayEvent, Cancellable, Living { + LivingEntity getNewTarget(); + LivingChangeTargetEvent.ILivingTargetType getTargetType(); +} diff --git a/src/main/java/vazkii/zeta/event/ZLivingConversion.java b/src/main/java/vazkii/zeta/event/ZLivingConversion.java index 42884c452a..4de0376174 100644 --- a/src/main/java/vazkii/zeta/event/ZLivingConversion.java +++ b/src/main/java/vazkii/zeta/event/ZLivingConversion.java @@ -2,11 +2,10 @@ import net.minecraft.world.entity.LivingEntity; import vazkii.zeta.event.bus.IZetaPlayEvent; +import vazkii.zeta.event.bus.Living; -public interface ZLivingConversion extends IZetaPlayEvent { - LivingEntity getEntity(); - - interface Post extends IZetaPlayEvent, ZLivingConversion { +public interface ZLivingConversion extends IZetaPlayEvent, Living { + interface Post extends ZLivingConversion { LivingEntity getOutcome(); } } diff --git a/src/main/java/vazkii/zeta/event/ZLivingDrops.java b/src/main/java/vazkii/zeta/event/ZLivingDrops.java index 027f0489f8..c50411e630 100644 --- a/src/main/java/vazkii/zeta/event/ZLivingDrops.java +++ b/src/main/java/vazkii/zeta/event/ZLivingDrops.java @@ -1,14 +1,13 @@ package vazkii.zeta.event; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import vazkii.zeta.event.bus.IZetaPlayEvent; +import vazkii.zeta.event.bus.Living; import java.util.Collection; -public interface ZLivingDrops extends IZetaPlayEvent { - LivingEntity getEntity(); +public interface ZLivingDrops extends IZetaPlayEvent, Living { Collection getDrops(); DamageSource getSource(); } diff --git a/src/main/java/vazkii/zeta/event/ZLivingSpawn.java b/src/main/java/vazkii/zeta/event/ZLivingSpawn.java new file mode 100644 index 0000000000..4c75ad67a6 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZLivingSpawn.java @@ -0,0 +1,22 @@ +package vazkii.zeta.event; + +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.level.BaseSpawner; +import net.minecraft.world.level.LevelAccessor; +import vazkii.zeta.event.bus.IZetaPlayEvent; +import vazkii.zeta.event.bus.Resultable; + +public interface ZLivingSpawn extends IZetaPlayEvent, Resultable { + Mob getEntity(); + LevelAccessor getLevel(); + double getX(); + double getY(); + double getZ(); + interface CheckSpawn extends ZLivingSpawn { + BaseSpawner getSpawner(); + MobSpawnType getSpawnReason(); + + interface Lowest extends CheckSpawn { } + } +} diff --git a/src/main/java/vazkii/zeta/event/ZPlayerDestroyItem.java b/src/main/java/vazkii/zeta/event/ZPlayerDestroyItem.java new file mode 100644 index 0000000000..00209d485b --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZPlayerDestroyItem.java @@ -0,0 +1,12 @@ +package vazkii.zeta.event; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZPlayerDestroyItem extends IZetaPlayEvent { + Player getEntity(); + ItemStack getOriginal(); + InteractionHand getHand(); +} diff --git a/src/main/java/vazkii/zeta/event/ZPlayerInteract.java b/src/main/java/vazkii/zeta/event/ZPlayerInteract.java new file mode 100644 index 0000000000..35ba0864fd --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZPlayerInteract.java @@ -0,0 +1,17 @@ +package vazkii.zeta.event; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import vazkii.zeta.event.bus.Cancellable; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +public interface ZPlayerInteract extends IZetaPlayEvent, Cancellable { + Player getEntity(); + InteractionHand getHand(); + void setCancellationResult(InteractionResult result); + interface EntityInteractSpecific extends ZPlayerInteract { + Entity getTarget(); + } +} diff --git a/src/main/java/vazkii/zeta/event/ZSleepingLocationCheck.java b/src/main/java/vazkii/zeta/event/ZSleepingLocationCheck.java new file mode 100644 index 0000000000..76ceaf7436 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/ZSleepingLocationCheck.java @@ -0,0 +1,10 @@ +package vazkii.zeta.event; + +import net.minecraft.core.BlockPos; +import vazkii.zeta.event.bus.IZetaPlayEvent; +import vazkii.zeta.event.bus.Living; +import vazkii.zeta.event.bus.Resultable; + +public interface ZSleepingLocationCheck extends IZetaPlayEvent, Living, Resultable { + BlockPos getSleepingLocation(); +} diff --git a/src/main/java/vazkii/zeta/event/bus/Living.java b/src/main/java/vazkii/zeta/event/bus/Living.java new file mode 100644 index 0000000000..5d6c0b2064 --- /dev/null +++ b/src/main/java/vazkii/zeta/event/bus/Living.java @@ -0,0 +1,7 @@ +package vazkii.zeta.event.bus; + +import net.minecraft.world.entity.LivingEntity; + +public interface Living { + LivingEntity getEntity(); +} diff --git a/src/main/java/vazkii/zetaimplforge/ForgeZeta.java b/src/main/java/vazkii/zetaimplforge/ForgeZeta.java index 3d573fab9d..21755b6810 100644 --- a/src/main/java/vazkii/zetaimplforge/ForgeZeta.java +++ b/src/main/java/vazkii/zetaimplforge/ForgeZeta.java @@ -1,7 +1,5 @@ package vazkii.zetaimplforge; -import java.util.Map; - import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.LivingEntity; @@ -11,25 +9,20 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.phys.BlockHitResult; -import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.ToolActions; -import net.minecraftforge.event.AddReloadListenerEvent; -import net.minecraftforge.event.AnvilUpdateEvent; -import net.minecraftforge.event.LootTableLoadEvent; -import net.minecraftforge.event.TagsUpdatedEvent; -import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.*; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.event.entity.EntityEvent; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.event.entity.EntityMobGriefingEvent; -import net.minecraftforge.event.entity.living.LivingConversionEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.living.*; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; import net.minecraftforge.event.level.NoteBlockEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.EventPriority; @@ -42,13 +35,13 @@ import net.minecraftforge.registries.RegisterEvent; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; -import vazkii.zeta.event.*; -import vazkii.zeta.registry.BrewingRegistry; import vazkii.zeta.Zeta; import vazkii.zeta.config.IZetaConfigInternals; import vazkii.zeta.config.SectionDefinition; +import vazkii.zeta.event.*; import vazkii.zeta.event.bus.ZResult; import vazkii.zeta.network.ZetaNetworkHandler; +import vazkii.zeta.registry.BrewingRegistry; import vazkii.zeta.registry.CraftingExtensionsRegistry; import vazkii.zeta.registry.ZetaRegistry; import vazkii.zeta.util.ZetaSide; @@ -60,6 +53,8 @@ import vazkii.zetaimplforge.registry.ForgeCraftingExtensionsRegistry; import vazkii.zetaimplforge.registry.ForgeZetaRegistry; +import java.util.Map; + /** * ideally do not touch quark from this package, it will later be split off */ @@ -177,13 +172,28 @@ public void start() { MinecraftForge.EVENT_BUS.addListener(this::livingConversion); MinecraftForge.EVENT_BUS.addListener(this::livingConversionPost); MinecraftForge.EVENT_BUS.addListener(this::anvilUpdate); - MinecraftForge.EVENT_BUS.addListener(this::anvilUpdateLowest); + MinecraftForge.EVENT_BUS.addListener(EventPriority.LOWEST, this::anvilUpdateLowest); MinecraftForge.EVENT_BUS.addListener(this::entityConstruct); MinecraftForge.EVENT_BUS.addListener(this::entityInteract); MinecraftForge.EVENT_BUS.addListener(this::entityMobGriefing); MinecraftForge.EVENT_BUS.addListener(this::livingDrops); MinecraftForge.EVENT_BUS.addListener(this::playerTickStart); MinecraftForge.EVENT_BUS.addListener(this::playerTickEnd); + MinecraftForge.EVENT_BUS.addListener(this::babyEntitySpawn); + MinecraftForge.EVENT_BUS.addListener(this::babyEntitySpawnLowest); + MinecraftForge.EVENT_BUS.addListener(this::entityJoinLevel); + //fixme + //MinecraftForge.EVENT_BUS.addGenericListener(ForgeZeta.class, this::attachCapabilities); + MinecraftForge.EVENT_BUS.addListener(this::levelTickStart); + MinecraftForge.EVENT_BUS.addListener(this::levelTickEnd); + MinecraftForge.EVENT_BUS.addListener(this::playerInteract); + MinecraftForge.EVENT_BUS.addListener(this::playerInteractEntityInteractSpecific); + MinecraftForge.EVENT_BUS.addListener(this::playerDestroyItem); + MinecraftForge.EVENT_BUS.addListener(this::livingSpawn); + MinecraftForge.EVENT_BUS.addListener(this::livingSpawnCheckSpawn); + MinecraftForge.EVENT_BUS.addListener(this::livingSpawnCheckSpawnLowest); + MinecraftForge.EVENT_BUS.addListener(this::livingChangeTarget); + MinecraftForge.EVENT_BUS.addListener(this::sleepingLocationCheck); } boolean registerDone = false; @@ -282,15 +292,73 @@ public void livingDrops(LivingDropsEvent e) { } public void playerTickStart(TickEvent.PlayerTickEvent e) { - if(e.phase == TickEvent.Phase.START) + if (e.phase == TickEvent.Phase.START) playBus.fire(new ForgeZPlayerTick.Start(e), ZPlayerTick.Start.class); } public void playerTickEnd(TickEvent.PlayerTickEvent e) { - if(e.phase == TickEvent.Phase.END) + if (e.phase == TickEvent.Phase.END) playBus.fire(new ForgeZPlayerTick.End(e), ZPlayerTick.End.class); } + public void babyEntitySpawn(BabyEntitySpawnEvent e) { + playBus.fire(new ForgeZBabyEntitySpawn(e), ZBabyEntitySpawn.class); + } + + public void babyEntitySpawnLowest(BabyEntitySpawnEvent e) { + playBus.fire(new ForgeZBabyEntitySpawn.Lowest(e), ZBabyEntitySpawn.Lowest.class); + } + + public void entityJoinLevel(EntityJoinLevelEvent e) { + playBus.fire(new ForgeZEntityJoinLevel(e), ZEntityJoinLevel.class); + } + + public void attachCapabilities(AttachCapabilitiesEvent e) { + playBus.fire(new ForgeZAttachCapabilities<>(e), ZAttachCapabilities.class); + } + + public void levelTickStart(TickEvent.LevelTickEvent e) { + if (e.phase == TickEvent.Phase.START) + playBus.fire(new ForgeZLevelTick.Start(e), ZLevelTick.Start.class); + } + + public void levelTickEnd(TickEvent.LevelTickEvent e) { + if (e.phase == TickEvent.Phase.END) + playBus.fire(new ForgeZLevelTick.End(e), ZLevelTick.End.class); + } + + public void playerInteract(PlayerInteractEvent e) { + playBus.fire(new ForgeZPlayerInteract(e), ZPlayerInteract.class); + } + + public void playerInteractEntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific e) { + playBus.fire(new ForgeZPlayerInteract.EntityInteractSpecific(e), ZPlayerInteract.EntityInteractSpecific.class); + } + + public void playerDestroyItem(PlayerDestroyItemEvent e) { + playBus.fire(new ForgeZPlayerDestroyItem(e), ZPlayerDestroyItem.class); + } + + public void livingSpawn(LivingSpawnEvent e) { + playBus.fire(new ForgeZLivingSpawn(e), ZLivingSpawn.class); + } + + public void livingSpawnCheckSpawn(LivingSpawnEvent.CheckSpawn e) { + playBus.fire(new ForgeZLivingSpawn.CheckSpawn(e), ZLivingSpawn.CheckSpawn.class); + } + + public void livingSpawnCheckSpawnLowest(LivingSpawnEvent.CheckSpawn e) { + playBus.fire(new ForgeZLivingSpawn.CheckSpawn.Lowest(e), ZLivingSpawn.CheckSpawn.Lowest.class); + } + + public void livingChangeTarget(LivingChangeTargetEvent e) { + playBus.fire(new ForgeZLivingChangeTarget(e), ZLivingChangeTarget.class); + } + + public void sleepingLocationCheck(SleepingLocationCheckEvent e) { + playBus.fire(new ForgeZSleepingLocationCheck(e), ZSleepingLocationCheck.class); + } + public static ZResult from(Event.Result r) { return switch(r) { case DENY -> ZResult.DENY; diff --git a/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java b/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java index fbf370ac10..13def48604 100644 --- a/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java +++ b/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java @@ -23,9 +23,9 @@ import net.minecraftforge.client.event.*; import vazkii.zeta.client.event.*; -import vazkii.zeta.event.ZInputEvent; +import vazkii.zeta.client.event.ZInput; import vazkii.zetaimplforge.client.event.*; -import vazkii.zetaimplforge.event.ForgeZInputEvent; +import vazkii.zetaimplforge.client.event.ForgeZInput; public class ForgeZetaClient extends ZetaClient { public ForgeZetaClient(Zeta z) { @@ -69,8 +69,8 @@ public void start() { MinecraftForge.EVENT_BUS.addListener(this::renderTick); MinecraftForge.EVENT_BUS.addListener(this::clientTick); - MinecraftForge.EVENT_BUS.addListener(this::clicc); - MinecraftForge.EVENT_BUS.addListener(this::prece); + MinecraftForge.EVENT_BUS.addListener(this::inputMouseButton); + MinecraftForge.EVENT_BUS.addListener(this::inputKey); MinecraftForge.EVENT_BUS.addListener(this::screenshot); MinecraftForge.EVENT_BUS.addListener(this::movementInputUpdate); MinecraftForge.EVENT_BUS.addListener(this::renderBlockHighlight); @@ -80,22 +80,29 @@ public void start() { MinecraftForge.EVENT_BUS.addListener(this::renderContainerScreenForeground); MinecraftForge.EVENT_BUS.addListener(this::renderContainerScreenBackground); - MinecraftForge.EVENT_BUS.addListener(this::screenCharacterTypedPre); - MinecraftForge.EVENT_BUS.addListener(this::screenCharacterTypedPost); - MinecraftForge.EVENT_BUS.addListener(this::screenInitPre); - MinecraftForge.EVENT_BUS.addListener(this::screenInitPost); - MinecraftForge.EVENT_BUS.addListener(this::screenKeyPressedPre); - MinecraftForge.EVENT_BUS.addListener(this::screenKeyPressedPost); - MinecraftForge.EVENT_BUS.addListener(this::screenMousePressedPre); - MinecraftForge.EVENT_BUS.addListener(this::screenMousePressedPost); MinecraftForge.EVENT_BUS.addListener(this::renderGameOverlayNeitherPreNorPost); - MinecraftForge.EVENT_BUS.addListener(this::renderGameOverlayPre); - MinecraftForge.EVENT_BUS.addListener(this::renderGameOverlayPost); + MinecraftForge.EVENT_BUS.addListener(this::renderGuiOverlayPre); + MinecraftForge.EVENT_BUS.addListener(this::renderGuiOverlayPost); MinecraftForge.EVENT_BUS.addListener(this::renderPlayerPre); MinecraftForge.EVENT_BUS.addListener(this::renderPlayerPost); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGHEST, this::renderLivingPreHighest); MinecraftForge.EVENT_BUS.addListener(EventPriority.LOWEST, this::renderLivingPostLowest); + MinecraftForge.EVENT_BUS.addListener(this::renderTooltipGatherComponents); + MinecraftForge.EVENT_BUS.addListener(this::renderTooltipGatherComponentsLow); + + MinecraftForge.EVENT_BUS.addListener(this::screenInitPre); + MinecraftForge.EVENT_BUS.addListener(this::screenInitPost); + MinecraftForge.EVENT_BUS.addListener(this::screenRenderPre); + MinecraftForge.EVENT_BUS.addListener(this::screenRenderPost); + MinecraftForge.EVENT_BUS.addListener(this::screenMouseButtonPressedPre); + MinecraftForge.EVENT_BUS.addListener(this::screenMouseButtonPressedPost); + MinecraftForge.EVENT_BUS.addListener(this::screenMouseScrolledPre); + MinecraftForge.EVENT_BUS.addListener(this::screenMouseScrolledPost); + MinecraftForge.EVENT_BUS.addListener(this::screenKeyPressedPre); + MinecraftForge.EVENT_BUS.addListener(this::screenKeyPressedPost); + MinecraftForge.EVENT_BUS.addListener(this::screenCharacterTypedPre); + MinecraftForge.EVENT_BUS.addListener(this::screenCharacterTypedPost); } public void registerBlockColors(RegisterColorHandlersEvent.Block event) { @@ -164,12 +171,12 @@ public void clientTick(TickEvent.ClientTickEvent event) { playBus.fire(new ZEndClientTick()); } - public void clicc(InputEvent.MouseButton e) { - playBus.fire(new ForgeZInputEvent.MouseButton(e), ZInputEvent.MouseButton.class); + public void inputMouseButton(InputEvent.MouseButton e) { + playBus.fire(new ForgeZInput.MouseButton(e), ZInput.MouseButton.class); } - public void prece(InputEvent.Key e) { - playBus.fire(new ForgeZInputEvent.Key(e), ZInputEvent.Key.class); + public void inputKey(InputEvent.Key e) { + playBus.fire(new ForgeZInput.Key(e), ZInput.Key.class); } public void screenshot(ScreenshotEvent e) { @@ -200,77 +207,117 @@ public void renderContainerScreenBackground(ContainerScreenEvent.Render.Backgrou playBus.fire(new ForgeZRenderContainerScreen.Background(e), ZRenderContainerScreen.Background.class); } - public void screenCharacterTypedPre(ScreenEvent.CharacterTyped.Pre e) { - playBus.fire(new ForgeZScreenCharacterTyped.Pre(e), ZScreenCharacterTyped.Pre.class); + //TODO: This probably should have been a PRE/POST event (just copying quark here) + public void renderGameOverlayNeitherPreNorPost(RenderGuiOverlayEvent e) { + if(e.getOverlay() == VanillaGuiOverlay.CROSSHAIR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Crosshair(e), ZRenderGuiOverlay.Crosshair.class); + else if(e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Hotbar(e), ZRenderGuiOverlay.Hotbar.class); + } + + public void renderGuiOverlayPre(RenderGuiOverlayEvent.Pre e) { + if (e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Hotbar.Pre(e), ZRenderGuiOverlay.Hotbar.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.CROSSHAIR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Crosshair.Pre(e), ZRenderGuiOverlay.Crosshair.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.PLAYER_HEALTH.type()) + playBus.fire(new ForgeZRenderGuiOverlay.PlayerHealth.Pre(e), ZRenderGuiOverlay.PlayerHealth.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.ARMOR_LEVEL.type()) + playBus.fire(new ForgeZRenderGuiOverlay.ArmorLevel.Pre(e), ZRenderGuiOverlay.ArmorLevel.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.DEBUG_TEXT.type()) + playBus.fire(new ForgeZRenderGuiOverlay.DebugText.Pre(e), ZRenderGuiOverlay.DebugText.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.POTION_ICONS.type()) + playBus.fire(new ForgeZRenderGuiOverlay.PotionIcons.Pre(e), ZRenderGuiOverlay.PotionIcons.Pre.class); + else if (e.getOverlay() == VanillaGuiOverlay.CHAT_PANEL.type()) + playBus.fire(new ForgeZRenderGuiOverlay.ChatPanel.Pre(e), ZRenderGuiOverlay.ChatPanel.Pre.class); + } + + public void renderGuiOverlayPost(RenderGuiOverlayEvent.Post e) { + if (e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Hotbar.Post(e), ZRenderGuiOverlay.Hotbar.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.CROSSHAIR.type()) + playBus.fire(new ForgeZRenderGuiOverlay.Crosshair.Post(e), ZRenderGuiOverlay.Crosshair.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.PLAYER_HEALTH.type()) + playBus.fire(new ForgeZRenderGuiOverlay.PlayerHealth.Post(e), ZRenderGuiOverlay.PlayerHealth.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.ARMOR_LEVEL.type()) + playBus.fire(new ForgeZRenderGuiOverlay.ArmorLevel.Post(e), ZRenderGuiOverlay.ArmorLevel.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.DEBUG_TEXT.type()) + playBus.fire(new ForgeZRenderGuiOverlay.DebugText.Post(e), ZRenderGuiOverlay.DebugText.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.POTION_ICONS.type()) + playBus.fire(new ForgeZRenderGuiOverlay.PotionIcons.Post(e), ZRenderGuiOverlay.PotionIcons.Post.class); + else if (e.getOverlay() == VanillaGuiOverlay.CHAT_PANEL.type()) + playBus.fire(new ForgeZRenderGuiOverlay.ChatPanel.Post(e), ZRenderGuiOverlay.ChatPanel.Post.class); } - public void screenCharacterTypedPost(ScreenEvent.CharacterTyped.Post e) { - playBus.fire(new ForgeZScreenCharacterTyped.Post(e), ZScreenCharacterTyped.Post.class); + public void renderPlayerPre(RenderPlayerEvent.Pre e) { + playBus.fire(new ForgeZRenderPlayer.Pre(e), ZRenderPlayer.Pre.class); + } + + public void renderPlayerPost(RenderPlayerEvent.Post e) { + playBus.fire(new ForgeZRenderPlayer.Post(e), ZRenderPlayer.Post.class); + } + + public void renderLivingPreHighest(RenderLivingEvent.Pre e) { + playBus.fire(new ForgeZRenderLiving.PreHighest(e), ZRenderLiving.PreHighest.class); + } + + public void renderLivingPostLowest(RenderLivingEvent.Post e) { + playBus.fire(new ForgeZRenderLiving.PostLowest(e), ZRenderLiving.PostLowest.class); + } + + public void renderTooltipGatherComponents(RenderTooltipEvent.GatherComponents e) { + playBus.fire(new ForgeZRenderTooltip.GatherComponents(e), ZRenderTooltip.GatherComponents.class); + } + + public void renderTooltipGatherComponentsLow(RenderTooltipEvent.GatherComponents e) { + playBus.fire(new ForgeZRenderTooltip.GatherComponents.Low(e), ZRenderTooltip.GatherComponents.Low.class); } public void screenInitPre(ScreenEvent.Init.Pre e) { - playBus.fire(new ForgeZScreenInit.Pre(e), ZScreenInit.Pre.class); + playBus.fire(new ForgeZScreen.Init.Pre(e), ZScreen.Init.Pre.class); } public void screenInitPost(ScreenEvent.Init.Post e) { - playBus.fire(new ForgeZScreenInit.Post(e), ZScreenInit.Post.class); - } - - public void screenKeyPressedPre(ScreenEvent.KeyPressed.Pre e) { - playBus.fire(new ForgeZScreenKeyPressed.Pre(e), ZScreenKeyPressed.Pre.class); + playBus.fire(new ForgeZScreen.Init.Post(e), ZScreen.Init.Post.class); } - public void screenKeyPressedPost(ScreenEvent.KeyPressed.Post e) { - playBus.fire(new ForgeZScreenKeyPressed.Post(e), ZScreenKeyPressed.Post.class); + public void screenRenderPre(ScreenEvent.Render.Pre e) { + playBus.fire(new ForgeZScreen.Render.Pre(e), ZScreen.Render.Pre.class); } - public void screenMousePressedPre(ScreenEvent.MouseButtonPressed.Pre e) { - playBus.fire(new ForgeZScreenMousePressed.Pre(e), ZScreenMousePressed.Pre.class); + public void screenRenderPost(ScreenEvent.Render.Post e) { + playBus.fire(new ForgeZScreen.Render.Post(e), ZScreen.Render.Post.class); } - public void screenMousePressedPost(ScreenEvent.MouseButtonPressed.Post e) { - playBus.fire(new ForgeZScreenMousePressed.Post(e), ZScreenMousePressed.Post.class); + public void screenMouseButtonPressedPre(ScreenEvent.MouseButtonPressed.Pre e) { + playBus.fire(new ForgeZScreen.MouseButtonPressed.Pre(e), ZScreen.MouseButtonPressed.Pre.class); } - //TODO: This probably should have been a PRE/POST event (just copying quark here) - public void renderGameOverlayNeitherPreNorPost(RenderGuiOverlayEvent e) { - if(e.getOverlay() == VanillaGuiOverlay.CROSSHAIR.type()) - playBus.fire(new ForgeZRenderOverlay.Crosshair(e), ZRenderOverlay.Crosshair.class); - else if(e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) - playBus.fire(new ForgeZRenderOverlay.Hotbar(e), ZRenderOverlay.Hotbar.class); + public void screenMouseButtonPressedPost(ScreenEvent.MouseButtonPressed.Post e) { + playBus.fire(new ForgeZScreen.MouseButtonPressed.Post(e), ZScreen.MouseButtonPressed.Post.class); } - public void renderGameOverlayPre(RenderGuiOverlayEvent.Pre e) { - if(e.getOverlay() == VanillaGuiOverlay.ARMOR_LEVEL.type()) - playBus.fire(new ForgeZRenderOverlay.ArmorLevel.Pre(e), ZRenderOverlay.ArmorLevel.Pre.class); - else if(e.getOverlay() == VanillaGuiOverlay.CHAT_PANEL.type()) - playBus.fire(new ForgeZRenderOverlay.Chat.Pre(e), ZRenderOverlay.Chat.Pre.class); - else if(e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) - playBus.fire(new ForgeZRenderOverlay.Hotbar.Pre(e), ZRenderOverlay.Hotbar.Pre.class); + public void screenMouseScrolledPre(ScreenEvent.MouseScrolled.Pre e) { + playBus.fire(new ForgeZScreen.MouseScrolled.Pre(e), ZScreen.MouseScrolled.Pre.class); } - public void renderGameOverlayPost(RenderGuiOverlayEvent.Post e) { - if(e.getOverlay() == VanillaGuiOverlay.ARMOR_LEVEL.type()) - playBus.fire(new ForgeZRenderOverlay.ArmorLevel.Post(e), ZRenderOverlay.ArmorLevel.Post.class); - else if(e.getOverlay() == VanillaGuiOverlay.CHAT_PANEL.type()) - playBus.fire(new ForgeZRenderOverlay.Chat.Post(e), ZRenderOverlay.Chat.Post.class); - else if(e.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) - playBus.fire(new ForgeZRenderOverlay.Hotbar.Post(e), ZRenderOverlay.Hotbar.Post.class); + public void screenMouseScrolledPost(ScreenEvent.MouseScrolled.Post e) { + playBus.fire(new ForgeZScreen.MouseScrolled.Post(e), ZScreen.MouseScrolled.Post.class); } - public void renderPlayerPre(RenderPlayerEvent.Pre e) { - playBus.fire(new ForgeZRenderPlayer.Pre(e), ZRenderPlayer.Pre.class); + public void screenKeyPressedPre(ScreenEvent.KeyPressed.Pre e) { + playBus.fire(new ForgeZScreen.KeyPressed.Pre(e), ZScreen.KeyPressed.Pre.class); } - public void renderPlayerPost(RenderPlayerEvent.Post e) { - playBus.fire(new ForgeZRenderPlayer.Post(e), ZRenderPlayer.Post.class); + public void screenKeyPressedPost(ScreenEvent.KeyPressed.Post e) { + playBus.fire(new ForgeZScreen.KeyPressed.Post(e), ZScreen.KeyPressed.Post.class); } - public void renderLivingPreHighest(RenderLivingEvent.Pre e) { - playBus.fire(new ForgeZRenderLiving.PreHighest(e), ZRenderLiving.PreHighest.class); + public void screenCharacterTypedPre(ScreenEvent.CharacterTyped.Pre e) { + playBus.fire(new ForgeZScreen.CharacterTyped.Pre(e), ZScreen.CharacterTyped.Pre.class); } - public void renderLivingPostLowest(RenderLivingEvent.Post e) { - playBus.fire(new ForgeZRenderLiving.PostLowest(e), ZRenderLiving.PostLowest.class); + public void screenCharacterTypedPost(ScreenEvent.CharacterTyped.Post e) { + playBus.fire(new ForgeZScreen.CharacterTyped.Post(e), ZScreen.CharacterTyped.Post.class); } } diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZInputEvent.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZInput.java similarity index 63% rename from src/main/java/vazkii/zetaimplforge/event/ForgeZInputEvent.java rename to src/main/java/vazkii/zetaimplforge/client/event/ForgeZInput.java index 61d865b1f7..0b6dd99ff4 100644 --- a/src/main/java/vazkii/zetaimplforge/event/ForgeZInputEvent.java +++ b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZInput.java @@ -1,10 +1,10 @@ -package vazkii.zetaimplforge.event; +package vazkii.zetaimplforge.client.event; import net.minecraftforge.client.event.InputEvent; -import vazkii.zeta.event.ZInputEvent; +import vazkii.zeta.client.event.ZInput; -public class ForgeZInputEvent implements ZInputEvent { - public static class MouseButton extends ForgeZInputEvent implements ZInputEvent.MouseButton { +public class ForgeZInput implements ZInput { + public static class MouseButton extends ForgeZInput implements ZInput.MouseButton { private final InputEvent.MouseButton e; public MouseButton(InputEvent.MouseButton e) { @@ -17,7 +17,7 @@ public int getButton() { } } - public static class Key extends ForgeZInputEvent implements ZInputEvent.Key { + public static class Key extends ForgeZInput implements ZInput.Key { private final InputEvent.Key e; public Key(InputEvent.Key e) { diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderGuiOverlay.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderGuiOverlay.java new file mode 100644 index 0000000000..607f79b5bc --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderGuiOverlay.java @@ -0,0 +1,167 @@ +package vazkii.zetaimplforge.client.event; + +import com.mojang.blaze3d.platform.Window; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.Minecraft; +import net.minecraftforge.client.event.RenderGuiOverlayEvent; +import net.minecraftforge.client.gui.overlay.ForgeGui; +import vazkii.zeta.client.event.ZRenderGuiOverlay; + +public class ForgeZRenderGuiOverlay implements ZRenderGuiOverlay { + private final RenderGuiOverlayEvent e; + + public ForgeZRenderGuiOverlay(RenderGuiOverlayEvent e) { + this.e = e; + } + + @Override + public Window getWindow() { + return e.getWindow(); + } + + @Override + public PoseStack getPoseStack() { + return e.getPoseStack(); + } + + @Override + public float getPartialTick() { + return e.getPartialTick(); + } + + @Override + public boolean shouldDrawSurvivalElements() { + return Minecraft.getInstance().gui instanceof ForgeGui fgui && fgui.shouldDrawSurvivalElements(); + } + + @Override + public int getLeftHeight() { + return Minecraft.getInstance().gui instanceof ForgeGui fgui ? fgui.leftHeight : 39; + } + + public static class Hotbar extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.Hotbar { + public Hotbar(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.Hotbar implements ZRenderGuiOverlay.Hotbar.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.Hotbar implements ZRenderGuiOverlay.Hotbar.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class Crosshair extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.Crosshair { + public Crosshair(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.Crosshair implements ZRenderGuiOverlay.Crosshair.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.Crosshair implements ZRenderGuiOverlay.Crosshair.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class PlayerHealth extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.PlayerHealth { + public PlayerHealth(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.PlayerHealth implements ZRenderGuiOverlay.PlayerHealth.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.PlayerHealth implements ZRenderGuiOverlay.PlayerHealth.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class ArmorLevel extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.ArmorLevel { + public ArmorLevel(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.ArmorLevel implements ZRenderGuiOverlay.ArmorLevel.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.ArmorLevel implements ZRenderGuiOverlay.ArmorLevel.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class DebugText extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.DebugText { + public DebugText(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.DebugText implements ZRenderGuiOverlay.DebugText.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.DebugText implements ZRenderGuiOverlay.DebugText.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class PotionIcons extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.PotionIcons { + public PotionIcons(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.PotionIcons implements ZRenderGuiOverlay.PotionIcons.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.PotionIcons implements ZRenderGuiOverlay.PotionIcons.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } + + public static class ChatPanel extends ForgeZRenderGuiOverlay implements ZRenderGuiOverlay.ChatPanel { + public ChatPanel(RenderGuiOverlayEvent e) { + super(e); + } + + public static class Pre extends ForgeZRenderGuiOverlay.ChatPanel implements ZRenderGuiOverlay.ChatPanel.Pre { + public Pre(RenderGuiOverlayEvent.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZRenderGuiOverlay.ChatPanel implements ZRenderGuiOverlay.ChatPanel.Post { + public Post(RenderGuiOverlayEvent.Post e) { + super(e); + } + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderOverlay.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderOverlay.java deleted file mode 100644 index e63a32a01a..0000000000 --- a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderOverlay.java +++ /dev/null @@ -1,101 +0,0 @@ -package vazkii.zetaimplforge.client.event; - -import com.mojang.blaze3d.platform.Window; -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.Minecraft; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; -import net.minecraftforge.client.gui.overlay.ForgeGui; -import vazkii.zeta.client.event.ZRenderOverlay; - -public class ForgeZRenderOverlay implements ZRenderOverlay { - private final RenderGuiOverlayEvent e; - - public ForgeZRenderOverlay(RenderGuiOverlayEvent e) { - this.e = e; - } - - @Override - public Window getWindow() { - return e.getWindow(); - } - - @Override - public PoseStack getPoseStack() { - return e.getPoseStack(); - } - - @Override - public float getPartialTick() { - return e.getPartialTick(); - } - - @Override - public boolean shouldDrawSurvivalElements() { - return Minecraft.getInstance().gui instanceof ForgeGui fgui && fgui.shouldDrawSurvivalElements(); - } - - @Override - public int getLeftHeight() { - return Minecraft.getInstance().gui instanceof ForgeGui fgui ? fgui.leftHeight : 39; - } - - public static class ArmorLevel extends ForgeZRenderOverlay implements ZRenderOverlay.ArmorLevel { - public ArmorLevel(RenderGuiOverlayEvent e) { - super(e); - } - - public static class Pre extends ForgeZRenderOverlay.ArmorLevel implements ZRenderOverlay.ArmorLevel.Pre { - public Pre(RenderGuiOverlayEvent.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZRenderOverlay.ArmorLevel implements ZRenderOverlay.ArmorLevel.Post { - public Post(RenderGuiOverlayEvent.Post e) { - super(e); - } - } - } - - public static class Chat extends ForgeZRenderOverlay implements ZRenderOverlay.Chat { - public Chat(RenderGuiOverlayEvent e) { - super(e); - } - - public static class Pre extends ForgeZRenderOverlay.Chat implements ZRenderOverlay.Chat.Pre { - public Pre(RenderGuiOverlayEvent.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZRenderOverlay.Chat implements ZRenderOverlay.Chat.Post { - public Post(RenderGuiOverlayEvent.Post e) { - super(e); - } - } - } - - public static class Crosshair extends ForgeZRenderOverlay implements ZRenderOverlay.Crosshair { - public Crosshair(RenderGuiOverlayEvent e) { - super(e); - } - } - - public static class Hotbar extends ForgeZRenderOverlay implements ZRenderOverlay.Hotbar { - public Hotbar(RenderGuiOverlayEvent e) { - super(e); - } - - public static class Pre extends ForgeZRenderOverlay.Hotbar implements ZRenderOverlay.Hotbar.Pre { - public Pre(RenderGuiOverlayEvent.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZRenderOverlay.Hotbar implements ZRenderOverlay.Hotbar.Post { - public Post(RenderGuiOverlayEvent.Post e) { - super(e); - } - } - } -} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderTooltip.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderTooltip.java new file mode 100644 index 0000000000..525203b64f --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZRenderTooltip.java @@ -0,0 +1,36 @@ +package vazkii.zetaimplforge.client.event; + +import com.mojang.datafixers.util.Either; +import net.minecraft.network.chat.FormattedText; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.event.RenderTooltipEvent; +import vazkii.zeta.client.event.ZRenderTooltip; + +import java.util.List; + +public class ForgeZRenderTooltip implements ZRenderTooltip { + public static class GatherComponents extends ForgeZRenderTooltip implements ZRenderTooltip.GatherComponents { + private final RenderTooltipEvent.GatherComponents e; + + public GatherComponents(RenderTooltipEvent.GatherComponents e) { + this.e = e; + } + + @Override + public ItemStack getItemStack() { + return e.getItemStack(); + } + + @Override + public List> getTooltipElements() { + return e.getTooltipElements(); + } + + public static class Low extends ForgeZRenderTooltip.GatherComponents implements ZRenderTooltip.GatherComponents.Low { + public Low(RenderTooltipEvent.GatherComponents e) { + super(e); + } + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreen.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreen.java new file mode 100644 index 0000000000..31b1d5b803 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreen.java @@ -0,0 +1,263 @@ +package vazkii.zetaimplforge.client.event; + +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.components.events.GuiEventListener; +import net.minecraft.client.gui.screens.Screen; +import net.minecraftforge.client.event.ScreenEvent; +import vazkii.zeta.client.event.ZScreen; + +import java.util.List; + +public class ForgeZScreen implements ZScreen { + private final ScreenEvent e; + + public ForgeZScreen(ScreenEvent e) { + this.e = e; + } + + @Override + public Screen getScreen() { + return e.getScreen(); + } + + public static class Init extends ForgeZScreen implements ZScreen.Init { + private final ScreenEvent.Init e; + + public Init(ScreenEvent.Init e) { + super(e); + this.e = e; + } + + @Override + public List getListenersList() { + return e.getListenersList(); + } + + @Override + public void addListener(GuiEventListener listener) { + e.addListener(listener); + } + + @Override + public void removeListener(GuiEventListener listener) { + e.removeListener(listener); + } + + public static class Pre extends ForgeZScreen.Init implements ZScreen.Init.Pre { + public Pre(ScreenEvent.Init.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.Init implements ZScreen.Init.Post { + public Post(ScreenEvent.Init.Post e) { + super(e); + } + } + } + + public static class Render extends ForgeZScreen implements ZScreen.Render { + private final ScreenEvent.Render e; + + public Render(ScreenEvent.Render e) { + super(e); + this.e = e; + } + + @Override + public PoseStack getPoseStack() { + return e.getPoseStack(); + } + + @Override + public int getMouseX() { + return e.getMouseX(); + } + + @Override + public int getMouseY() { + return e.getMouseY(); + } + + public static class Pre extends ForgeZScreen.Render implements ZScreen.Render.Pre { + public Pre(ScreenEvent.Render e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.Render implements ZScreen.Render.Post { + public Post(ScreenEvent.Render e) { + super(e); + } + } + } + + public static class MouseButtonPressed extends ForgeZScreen implements ZScreen.MouseButtonPressed { + private final ScreenEvent.MouseButtonPressed e; + + public MouseButtonPressed(ScreenEvent.MouseButtonPressed e) { + super(e); + this.e = e; + } + + @Override + public int getButton() { + return e.getButton(); + } + + @Override + public double getMouseX() { + return e.getMouseX(); + } + + @Override + public double getMouseY() { + return e.getMouseY(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } + + public static class Pre extends ForgeZScreen.MouseButtonPressed implements ZScreen.MouseButtonPressed.Pre { + public Pre(ScreenEvent.MouseButtonPressed.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.MouseButtonPressed implements ZScreen.MouseButtonPressed.Post { + public Post(ScreenEvent.MouseButtonPressed.Post e) { + super(e); + } + } + } + + public static class MouseScrolled extends ForgeZScreen implements ZScreen.MouseScrolled { + private final ScreenEvent.MouseScrolled e; + + public MouseScrolled(ScreenEvent.MouseScrolled e) { + super(e); + this.e = e; + } + + @Override + public double getScrollDelta() { + return e.getScrollDelta(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } + + public static class Pre extends ForgeZScreen.MouseScrolled implements ZScreen.MouseScrolled.Pre { + public Pre(ScreenEvent.MouseScrolled.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.MouseScrolled implements ZScreen.MouseScrolled.Post { + public Post(ScreenEvent.MouseScrolled.Post e) { + super(e); + } + } + } + + public static class KeyPressed extends ForgeZScreen implements ZScreen.KeyPressed { + private final ScreenEvent.KeyPressed e; + + public KeyPressed(ScreenEvent.KeyPressed e) { + super(e); + this.e = e; + } + + @Override + public int getKeyCode() { + return e.getKeyCode(); + } + + @Override + public int getScanCode() { + return e.getScanCode(); + } + + @Override + public int getModifiers() { + return e.getModifiers(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } + + public static class Pre extends ForgeZScreen.KeyPressed implements ZScreen.KeyPressed.Pre { + public Pre(ScreenEvent.KeyPressed.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.KeyPressed implements ZScreen.KeyPressed.Post { + public Post(ScreenEvent.KeyPressed.Post e) { + super(e); + } + } + } + + public static class CharacterTyped extends ForgeZScreen implements ZScreen.CharacterTyped { + private final ScreenEvent.CharacterTyped e; + + public CharacterTyped(ScreenEvent.CharacterTyped e) { + super(e); + this.e = e; + } + + @Override + public char getCodePoint() { + return e.getCodePoint(); + } + + @Override + public int getModifiers() { + return e.getModifiers(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(true); + } + + public static class Pre extends ForgeZScreen.CharacterTyped implements ZScreen.CharacterTyped.Pre { + public Pre(ScreenEvent.CharacterTyped.Pre e) { + super(e); + } + } + + public static class Post extends ForgeZScreen.CharacterTyped implements ZScreen.CharacterTyped.Post { + public Post(ScreenEvent.CharacterTyped.Post e) { + super(e); + } + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenCharacterTyped.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenCharacterTyped.java deleted file mode 100644 index 1221f6f6eb..0000000000 --- a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenCharacterTyped.java +++ /dev/null @@ -1,50 +0,0 @@ -package vazkii.zetaimplforge.client.event; - -import net.minecraft.client.gui.screens.Screen; -import net.minecraftforge.client.event.ScreenEvent; -import vazkii.zeta.client.event.ZScreenCharacterTyped; - -public abstract class ForgeZScreenCharacterTyped implements ZScreenCharacterTyped { - private final ScreenEvent.CharacterTyped e; - - public ForgeZScreenCharacterTyped(ScreenEvent.CharacterTyped e) { - this.e = e; - } - - @Override - public Screen getScreen() { - return e.getScreen(); - } - - @Override - public char getCodePoint() { - return e.getCodePoint(); - } - - @Override - public int getModifiers() { - return e.getModifiers(); - } - - @Override - public boolean isCanceled() { - return e.isCanceled(); - } - - @Override - public void setCanceled(boolean cancel) { - e.setCanceled(true); - } - - public static class Pre extends ForgeZScreenCharacterTyped implements ZScreenCharacterTyped.Pre { - public Pre(ScreenEvent.CharacterTyped.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZScreenCharacterTyped implements ZScreenCharacterTyped.Post { - public Post(ScreenEvent.CharacterTyped.Post e) { - super(e); - } - } -} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenInit.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenInit.java deleted file mode 100644 index 40cddc8066..0000000000 --- a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenInit.java +++ /dev/null @@ -1,49 +0,0 @@ -package vazkii.zetaimplforge.client.event; - -import java.util.List; - -import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.screens.Screen; -import net.minecraftforge.client.event.ScreenEvent; -import vazkii.zeta.client.event.ZScreenInit; - -public class ForgeZScreenInit implements ZScreenInit { - - private final ScreenEvent.Init e; - - public ForgeZScreenInit(ScreenEvent.Init e) { - this.e = e; - } - - @Override - public Screen getScreen() { - return e.getScreen(); - } - - @Override - public List getListenersList() { - return e.getListenersList(); - } - - @Override - public void addListener(GuiEventListener listener) { - e.addListener(listener); - } - - @Override - public void removeListener(GuiEventListener listener) { - e.removeListener(listener); - } - - public static class Pre extends ForgeZScreenInit implements ZScreenInit.Pre { - public Pre(ScreenEvent.Init.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZScreenInit implements ZScreenInit.Post { - public Post(ScreenEvent.Init.Post e) { - super(e); - } - } -} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenKeyPressed.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenKeyPressed.java deleted file mode 100644 index 99b4f009dd..0000000000 --- a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenKeyPressed.java +++ /dev/null @@ -1,55 +0,0 @@ -package vazkii.zetaimplforge.client.event; - -import net.minecraft.client.gui.screens.Screen; -import net.minecraftforge.client.event.ScreenEvent; -import vazkii.zeta.client.event.ZScreenKeyPressed; - -public class ForgeZScreenKeyPressed implements ZScreenKeyPressed { - protected final ScreenEvent.KeyPressed e; - - public ForgeZScreenKeyPressed(ScreenEvent.KeyPressed e) { - this.e = e; - } - - @Override - public Screen getScreen() { - return e.getScreen(); - } - - @Override - public int getKeyCode() { - return e.getKeyCode(); - } - - @Override - public int getScanCode() { - return e.getScanCode(); - } - - @Override - public int getModifiers() { - return e.getModifiers(); - } - - @Override - public boolean isCanceled() { - return e.isCanceled(); - } - - @Override - public void setCanceled(boolean cancel) { - e.setCanceled(true); - } - - public static class Pre extends ForgeZScreenKeyPressed implements ZScreenKeyPressed.Pre { - public Pre(ScreenEvent.KeyPressed.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZScreenKeyPressed implements ZScreenKeyPressed.Post { - public Post(ScreenEvent.KeyPressed.Post e) { - super(e); - } - } -} diff --git a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenMousePressed.java b/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenMousePressed.java deleted file mode 100644 index 3905e24520..0000000000 --- a/src/main/java/vazkii/zetaimplforge/client/event/ForgeZScreenMousePressed.java +++ /dev/null @@ -1,55 +0,0 @@ -package vazkii.zetaimplforge.client.event; - -import net.minecraft.client.gui.screens.Screen; -import net.minecraftforge.client.event.ScreenEvent; -import vazkii.zeta.client.event.ZScreenMousePressed; - -public class ForgeZScreenMousePressed implements ZScreenMousePressed { - protected final ScreenEvent.MouseButtonPressed e; - - public ForgeZScreenMousePressed(ScreenEvent.MouseButtonPressed e) { - this.e = e; - } - - @Override - public Screen getScreen() { - return e.getScreen(); - } - - @Override - public int getButton() { - return e.getButton(); - } - - @Override - public double getMouseX() { - return e.getMouseX(); - } - - @Override - public double getMouseY() { - return e.getMouseY(); - } - - @Override - public boolean isCanceled() { - return e.isCanceled(); - } - - @Override - public void setCanceled(boolean cancel) { - e.setCanceled(cancel); - } - - public static class Pre extends ForgeZScreenMousePressed implements ZScreenMousePressed.Pre { - public Pre(ScreenEvent.MouseButtonPressed.Pre e) { - super(e); - } - } - - public static class Post extends ForgeZScreenMousePressed implements ZScreenMousePressed.Post { - public Post(ScreenEvent.MouseButtonPressed.Post e) { - super(e); - } - } -} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZAttachCapabilities.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZAttachCapabilities.java new file mode 100644 index 0000000000..676abfc95c --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZAttachCapabilities.java @@ -0,0 +1,24 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.event.AttachCapabilitiesEvent; +import vazkii.zeta.event.ZAttachCapabilities; + +public class ForgeZAttachCapabilities implements ZAttachCapabilities { + private final AttachCapabilitiesEvent e; + + public ForgeZAttachCapabilities(AttachCapabilitiesEvent e) { + this.e = e; + } + + @Override + public T getObject() { + return e.getObject(); + } + + @Override + public void addCapability(ResourceLocation key, ICapabilityProvider cap) { + e.addCapability(key, cap); + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZBabyEntitySpawn.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZBabyEntitySpawn.java new file mode 100644 index 0000000000..45b3da0dd1 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZBabyEntitySpawn.java @@ -0,0 +1,32 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.AnvilUpdateEvent; +import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent; +import vazkii.zeta.event.ZAnvilUpdate; +import vazkii.zeta.event.ZBabyEntitySpawn; + +public class ForgeZBabyEntitySpawn implements ZBabyEntitySpawn { + private final BabyEntitySpawnEvent e; + + public ForgeZBabyEntitySpawn(BabyEntitySpawnEvent e) { + this.e = e; + } + + @Override + public Mob getParentA() { + return e.getParentA(); + } + + @Override + public Player getCausedByPlayer() { + return e.getCausedByPlayer(); + } + + public static class Lowest extends ForgeZBabyEntitySpawn implements ZBabyEntitySpawn.Lowest { + public Lowest(BabyEntitySpawnEvent e) { + super(e); + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZEntityJoinLevel.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZEntityJoinLevel.java new file mode 100644 index 0000000000..24932d47d4 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZEntityJoinLevel.java @@ -0,0 +1,28 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.entity.Entity; +import net.minecraftforge.event.entity.EntityJoinLevelEvent; +import vazkii.zeta.event.ZEntityJoinLevel; + +public class ForgeZEntityJoinLevel implements ZEntityJoinLevel { + private final EntityJoinLevelEvent e; + + public ForgeZEntityJoinLevel(EntityJoinLevelEvent e) { + this.e = e; + } + + @Override + public Entity getEntity() { + return e.getEntity(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZLevelTick.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZLevelTick.java new file mode 100644 index 0000000000..532a2eaa39 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZLevelTick.java @@ -0,0 +1,31 @@ +package vazkii.zetaimplforge.event; + + +import net.minecraft.world.level.Level; +import net.minecraftforge.event.TickEvent; +import vazkii.zeta.event.ZLevelTick; + +public class ForgeZLevelTick implements ZLevelTick { + private final TickEvent.LevelTickEvent e; + + public ForgeZLevelTick(TickEvent.LevelTickEvent e) { + this.e = e; + } + + @Override + public Level getLevel() { + return e.level; + } + + public static class Start extends ForgeZLevelTick implements ZLevelTick.Start { + public Start(TickEvent.LevelTickEvent e) { + super(e); + } + } + + public static class End extends ForgeZLevelTick implements ZLevelTick.End { + public End(TickEvent.LevelTickEvent e) { + super(e); + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingChangeTarget.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingChangeTarget.java new file mode 100644 index 0000000000..1e729834bf --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingChangeTarget.java @@ -0,0 +1,38 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraftforge.event.entity.living.LivingChangeTargetEvent; +import vazkii.zeta.event.ZLivingChangeTarget; + +public class ForgeZLivingChangeTarget implements ZLivingChangeTarget { + private final LivingChangeTargetEvent e; + + public ForgeZLivingChangeTarget(LivingChangeTargetEvent e) { + this.e = e; + } + + @Override + public LivingEntity getEntity() { + return e.getEntity(); + } + + @Override + public LivingEntity getNewTarget() { + return e.getNewTarget(); + } + + @Override + public LivingChangeTargetEvent.ILivingTargetType getTargetType() { + return e.getTargetType(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingSpawn.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingSpawn.java new file mode 100644 index 0000000000..3f94acfc8b --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZLivingSpawn.java @@ -0,0 +1,78 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.level.BaseSpawner; +import net.minecraft.world.level.LevelAccessor; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import vazkii.zeta.event.ZLivingSpawn; +import vazkii.zeta.event.bus.ZResult; +import vazkii.zetaimplforge.ForgeZeta; + +public class ForgeZLivingSpawn implements ZLivingSpawn { + private final LivingSpawnEvent e; + + public ForgeZLivingSpawn(LivingSpawnEvent e) { + this.e = e; + } + + @Override + public Mob getEntity() { + return e.getEntity(); + } + + @Override + public LevelAccessor getLevel() { + return e.getLevel(); + } + + @Override + public double getX() { + return e.getX(); + } + + @Override + public double getY() { + return e.getY(); + } + + @Override + public double getZ() { + return e.getZ(); + } + + @Override + public ZResult getResult() { + return ForgeZeta.from(e.getResult()); + } + + @Override + public void setResult(ZResult value) { + e.setResult(ForgeZeta.to(value)); + } + + public static class CheckSpawn extends ForgeZLivingSpawn implements ZLivingSpawn.CheckSpawn { + private final LivingSpawnEvent.CheckSpawn e; + + public CheckSpawn(LivingSpawnEvent.CheckSpawn e) { + super(e); + this.e = e; + } + + @Override + public BaseSpawner getSpawner() { + return e.getSpawner(); + } + + @Override + public MobSpawnType getSpawnReason() { + return e.getSpawnReason(); + } + + public static class Lowest extends ForgeZLivingSpawn.CheckSpawn implements ZLivingSpawn.CheckSpawn.Lowest { + public Lowest(LivingSpawnEvent.CheckSpawn e) { + super(e); + } + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerDestroyItem.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerDestroyItem.java new file mode 100644 index 0000000000..07a13975d2 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerDestroyItem.java @@ -0,0 +1,30 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import vazkii.zeta.event.ZPlayerDestroyItem; + +public class ForgeZPlayerDestroyItem implements ZPlayerDestroyItem { + private final PlayerDestroyItemEvent e; + + public ForgeZPlayerDestroyItem(PlayerDestroyItemEvent e) { + this.e = e; + } + + @Override + public Player getEntity() { + return e.getEntity(); + } + + @Override + public ItemStack getOriginal() { + return e.getOriginal(); + } + + @Override + public InteractionHand getHand() { + return e.getHand(); + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerInteract.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerInteract.java new file mode 100644 index 0000000000..96163c6b49 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZPlayerInteract.java @@ -0,0 +1,56 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import vazkii.zeta.event.ZPlayerInteract; + +public class ForgeZPlayerInteract implements ZPlayerInteract { + private final PlayerInteractEvent e; + + public ForgeZPlayerInteract(PlayerInteractEvent e) { + this.e = e; + } + + @Override + public Player getEntity() { + return e.getEntity(); + } + + @Override + public InteractionHand getHand() { + return e.getHand(); + } + + @Override + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); + } + + + @Override + public void setCancellationResult(InteractionResult result) { + e.setCancellationResult(result); + } + + public static class EntityInteractSpecific extends ForgeZPlayerInteract implements ZPlayerInteract.EntityInteractSpecific { + private final PlayerInteractEvent.EntityInteractSpecific e; + + public EntityInteractSpecific(PlayerInteractEvent.EntityInteractSpecific e) { + super(e); + this.e = e; + } + + @Override + public Entity getTarget() { + return e.getTarget(); + } + } +} diff --git a/src/main/java/vazkii/zetaimplforge/event/ForgeZSleepingLocationCheck.java b/src/main/java/vazkii/zetaimplforge/event/ForgeZSleepingLocationCheck.java new file mode 100644 index 0000000000..d2b67ce7d3 --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/event/ForgeZSleepingLocationCheck.java @@ -0,0 +1,37 @@ +package vazkii.zetaimplforge.event; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; +import vazkii.zeta.event.ZSleepingLocationCheck; +import vazkii.zeta.event.bus.ZResult; +import vazkii.zetaimplforge.ForgeZeta; + +public class ForgeZSleepingLocationCheck implements ZSleepingLocationCheck { + private final SleepingLocationCheckEvent e; + + public ForgeZSleepingLocationCheck(SleepingLocationCheckEvent e) { + this.e = e; + } + + @Override + public LivingEntity getEntity() { + return e.getEntity(); + } + + + @Override + public BlockPos getSleepingLocation() { + return e.getSleepingLocation(); + } + + @Override + public ZResult getResult() { + return ForgeZeta.from(e.getResult()); + } + + @Override + public void setResult(ZResult value) { + e.setResult(ForgeZeta.to(value)); + } +}