Skip to content

Commit

Permalink
feat: Zeta Porting (#4406)
Browse files Browse the repository at this point in the history
* chore: move event into client folder

* feat: Port automation modules

* chore: deprecate @LoadModule in favour of @ZetaLoadModule

* chore: remove unused imports

* chore: remove getPhases()

* Ported Building modules to zeta

* General cleanup and porting of missed modules

* more porting

* The great screen Event refactoring!

- Combine them all under ZScreen for cleanness

* ready for merge!

* management modules ported

* Mob modules ported
  • Loading branch information
IThundxr authored Nov 7, 2023
1 parent 772a06a commit 9ef86a8
Show file tree
Hide file tree
Showing 126 changed files with 2,276 additions and 1,593 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -33,20 +21,23 @@
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 {

private static final Multimap<ButtonTargetType, ButtonProviderHolder> providers = Multimaps.newSetMultimap(new HashMap<>(), TreeSet::new);
private static final Multimap<ButtonTargetType, Button> 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) {
Expand Down Expand Up @@ -91,7 +82,7 @@ private static Collection<ButtonProviderHolder> 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))
Expand All @@ -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))
Expand All @@ -131,7 +122,7 @@ public static void keyboardInputEvent(ZScreenKeyPressed.Pre pressed) {

}

private static void applyProviders(ZScreenInit.Post event, ButtonTargetType type, AbstractContainerScreen<?> screen, Predicate<Slot> slotPred) {
private static void applyProviders(ZScreen.Init.Post event, ButtonTargetType type, AbstractContainerScreen<?> screen, Predicate<Slot> slotPred) {
Collection<ButtonProviderHolder> holders = providers.get(type);
if(!holders.isEmpty()) {
for(Slot slot : screen.getMenu().slots)
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/vazkii/quark/base/handler/MiscUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/main/java/vazkii/quark/base/module/LoadModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ChuteBlockEntity> blockEntityType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> blacklist = Lists.newArrayList("minecraft:water", "minecraft:lava", "minecraft:fire");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnderWatcherBlockEntity> blockEntityType;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<FeedingTroughBlockEntity> blockEntityType;
Expand Down Expand Up @@ -84,14 +81,14 @@ public class FeedingTroughModule extends ZetaModule {

private static final ThreadLocal<Boolean> 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();
Expand Down Expand Up @@ -174,7 +171,7 @@ private static Set<BlockState> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gravisand> gravisandType;
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> ironRodImmuneTag;
Expand Down
Loading

0 comments on commit 9ef86a8

Please sign in to comment.