Skip to content

Commit

Permalink
Lot of Tweaks modules
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Nov 4, 2023
1 parent 8bc0265 commit 1709357
Show file tree
Hide file tree
Showing 55 changed files with 826 additions and 524 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class QButtonHandler {

@PlayEvent
public static void onGuiInit(ZScreenInit.Pre event) {
public static void onGuiInit(ZScreenInit.Post event) {
Screen gui = event.getScreen();

if(GeneralConfig.enableQButton && (gui instanceof TitleScreen || gui instanceof PauseScreen)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.commons.lang3.tuple.Pair;
import vazkii.quark.base.handler.advancement.QuarkAdvancementHandler;
import vazkii.quark.base.handler.advancement.mod.WaxModifier;
import vazkii.zeta.event.ZRightClickBlock;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.event.ZCommonSetup;
import vazkii.zeta.event.bus.LoadEvent;
Expand Down Expand Up @@ -82,8 +84,8 @@ public static void toolActionEvent(BlockEvent.BlockToolModificationEvent event)
}
}

@SubscribeEvent
public static void itemUse(PlayerInteractEvent.RightClickBlock event) {
@PlayEvent
public static void itemUse(ZRightClickBlock event) {
ItemStack stack = event.getItemStack();

if(stack.getItem() == Items.HONEYCOMB) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public EditSignMessage(BlockPos pos) {

@Override
public boolean receive(IZetaNetworkEventContext context) {
context.enqueueWork(() -> SignEditingModule.openSignGuiClient(pos));
context.enqueueWork(() -> SignEditingModule.Client.openSignGuiClient(pos));

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/vazkii/quark/base/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void start() {
Quark.ZETA.playBus
.subscribe(SyncedFlagHandler.class)
.subscribe(ContributorRewardHandler.class)
.subscribe(FuelHandler.class);
.subscribe(FuelHandler.class)
.subscribe(ToolInteractionHandler.class);

MinecraftForge.EVENT_BUS.register(CapabilityHandler.class);
MinecraftForge.EVENT_BUS.register(ToolInteractionHandler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public CustomEmoteDescriptor(String name, String regName, int index) {

public static ResourceLocation getSprite(String name) {
ResourceLocation customRes = new ResourceLocation(EmoteHandler.CUSTOM_EMOTE_NAMESPACE, name);
if(EmotesModule.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes))
if(EmotesModule.Client.resourcePack.hasResource(PackType.CLIENT_RESOURCES, customRes))
return customRes;

return new ResourceLocation("quark", "textures/emote/custom.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@OnlyIn(Dist.CLIENT)
public final class EmoteHandler {

public static final String CUSTOM_EMOTE_NAMESPACE = "quark_custom";
Expand Down Expand Up @@ -64,14 +61,12 @@ public static void addCustomEmote(String name) {
emoteMap.put(reg, desc);
}

@OnlyIn(Dist.CLIENT)
public static void putEmote(Entity player, String emoteName, int tier) {
if(player instanceof AbstractClientPlayer clientPlayer && emoteMap.containsKey(emoteName)) {
putEmote(clientPlayer, emoteMap.get(emoteName), tier);
}
}

@OnlyIn(Dist.CLIENT)
private static void putEmote(AbstractClientPlayer player, EmoteDescriptor desc, int tier) {
String name = player.getGameProfile().getName();
if(desc == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.event.ZEntityConstruct;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.util.Hint;

/**
* @author WireSegal
* Created at 8:40 AM on 8/27/19.
*/
@LoadModule(category = "tweaks", hasSubscriptions = true)
@ZetaLoadModule(category = "tweaks")
public class ArmedArmorStandsModule extends ZetaModule {

@Hint Item armor_stand = Items.ARMOR_STAND;

@SubscribeEvent
public void entityConstruct(EntityEvent.EntityConstructing event) {
@PlayEvent
public void entityConstruct(ZEntityConstruct event) {
if(event.getEntity() instanceof ArmorStand stand) {
if(!stand.isShowArms())
setShowArms(stand, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@
import net.minecraft.world.inventory.RecipeBookType;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.GameRules;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ScreenEvent.Init;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.Quark;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.client.event.ZEndClientTick;
import vazkii.zeta.client.event.ZScreenInit;
import vazkii.zeta.event.ZPlayerLoggedIn;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;
import vazkii.quark.base.module.config.Config;
import vazkii.zeta.event.ZConfigChanged;
import vazkii.zeta.event.bus.LoadEvent;

import java.util.*;

@LoadModule(category = "tweaks", hasSubscriptions = true)
@ZetaLoadModule(category = "tweaks")
public class AutomaticRecipeUnlockModule extends ZetaModule {

@Config(description = "A list of recipe names that should NOT be added in by default")
Expand All @@ -51,8 +49,8 @@ public final void configChanged(ZConfigChanged event) {
staticEnabled = enabled;
}

@SubscribeEvent
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
@PlayEvent
public void onPlayerLoggedIn(ZPlayerLoggedIn event) {
Player player = event.getEntity();

if(player instanceof ServerPlayer spe) {
Expand Down Expand Up @@ -86,40 +84,6 @@ public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
}
}

@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void onInitGui(Init.Post event) {
Screen gui = event.getScreen();
if(disableRecipeBook && gui instanceof RecipeUpdateListener) {
Minecraft.getInstance().player.getRecipeBook().getBookSettings().setOpen(RecipeBookType.CRAFTING, false);

List<GuiEventListener> widgets = event.getListenersList();
for(GuiEventListener w : widgets)
if(w instanceof ImageButton) {
event.removeListener(w);
return;
}
}
}

@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public void clientTick(ClientTickEvent event) {
Minecraft mc = Minecraft.getInstance();
if(mc.player != null && mc.player.tickCount < 20) {
ToastComponent toasts = mc.getToasts();
Queue<Toast> toastQueue = toasts.queued;
for(Toast toast : toastQueue)
if(toast instanceof RecipeToast recipeToast) {
List<Recipe<?>> stacks = recipeToast.recipes;
if(stacks.size() > 100) {
toastQueue.remove(toast);
return;
}
}
}
}

public static void removeRecipeAdvancements(Map<ResourceLocation, Advancement.Builder> builders) {
if (!staticEnabled || !filterRecipeAdvancements)
return;
Expand All @@ -134,4 +98,41 @@ public static void removeRecipeAdvancements(Map<ResourceLocation, Advancement.Bu
}
Quark.LOG.info("[Automatic Recipe Unlock] Removed {} recipe advancements", i);
}

@ZetaLoadModule(clientReplacement = true)
public static class Client extends AutomaticRecipeUnlockModule {

@PlayEvent
public void onInitGui(ZScreenInit.Post event) {
Screen gui = event.getScreen();
if(disableRecipeBook && gui instanceof RecipeUpdateListener) {
Minecraft.getInstance().player.getRecipeBook().getBookSettings().setOpen(RecipeBookType.CRAFTING, false);

List<GuiEventListener> widgets = event.getListenersList();
for(GuiEventListener w : widgets)
if(w instanceof ImageButton) {
event.removeListener(w);
return;
}
}
}

@PlayEvent
public void clientTick(ZEndClientTick event) {
Minecraft mc = Minecraft.getInstance();
if(mc.player != null && mc.player.tickCount < 20) {
ToastComponent toasts = mc.getToasts();
Queue<Toast> toastQueue = toasts.queued;
for(Toast toast : toastQueue)
if(toast instanceof RecipeToast recipeToast) {
List<Recipe<?>> stacks = recipeToast.recipes;
if(stacks.size() > 100) {
toastQueue.remove(toast);
return;
}
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import net.minecraft.world.item.FireworkRocketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.event.ZRightClickItem;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;

@LoadModule(category = "tweaks", hasSubscriptions = true)
@ZetaLoadModule(category = "tweaks")
public class BetterElytraRocketModule extends ZetaModule {

@SubscribeEvent
public void onUseRocket(PlayerInteractEvent.RightClickItem event) {
@PlayEvent
public void onUseRocket(ZRightClickItem event) {
Player player = event.getEntity();
if(!player.isFallFlying() && player.getItemBySlot(EquipmentSlot.CHEST).canElytraFly(player)) {
Level world = player.level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import net.minecraft.world.level.block.CampfireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.event.ZPlayerTick;
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;
import vazkii.quark.base.module.config.Config;
import vazkii.zeta.util.Hint;

@LoadModule(category = "tweaks", hasSubscriptions = true)
@ZetaLoadModule(category = "tweaks")
public class CampfiresBoostElytraModule extends ZetaModule {

@Config public double boostStrength = 0.5;
Expand All @@ -27,9 +27,9 @@ public class CampfiresBoostElytraModule extends ZetaModule {
@Hint Item campfire = Items.CAMPFIRE;
@Hint Item soul_campfire = Items.SOUL_CAMPFIRE;

@SubscribeEvent
public void onPlayerTick(PlayerTickEvent event) {
Player player = event.player;
@PlayEvent
public void onPlayerTick(ZPlayerTick.Start event) {
Player player = event.getPlayer();

if(player.isFallFlying()) {
Vec3 motion = player.getDeltaMovement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import vazkii.quark.base.module.LoadModule;
import vazkii.zeta.event.ZPlayerTick;
import vazkii.zeta.module.ZetaLoadModule;
import vazkii.zeta.module.ZetaModule;
import vazkii.quark.base.module.config.Config;
import vazkii.zeta.util.Hint;
Expand All @@ -24,7 +20,7 @@
import vazkii.zeta.event.bus.PlayEvent;
import vazkii.zeta.client.event.ZClientSetup;

@LoadModule(category = "tweaks", hasSubscriptions = true)
@ZetaLoadModule(category = "tweaks")
public class CompassesWorkEverywhereModule extends ZetaModule {

@Config public static boolean enableCompassNerf = true;
Expand All @@ -36,17 +32,6 @@ public class CompassesWorkEverywhereModule extends ZetaModule {

@Hint("clock_nerf") Item clock = Items.CLOCK;

@LoadEvent
@OnlyIn(Dist.CLIENT)
public void clientSetup(ZClientSetup e) {
// register = addPropertyOverride
if(enabled && (enableCompassNerf || enableNether || enableEnd))
e.enqueueWork(() -> ItemProperties.register(Items.COMPASS, new ResourceLocation("angle"), new CompassAngleGetter.Impl()));

if(enabled && enableClockNerf)
e.enqueueWork(() -> ItemProperties.register(Items.CLOCK, new ResourceLocation("time"), new ClockTimeGetter.Impl()));
}

@PlayEvent
public void addAdditionalHints(ZGatherHints consumer) {
if(!enableNether && !enableEnd && !enableCompassNerf)
Expand All @@ -68,18 +53,35 @@ public void addAdditionalHints(ZGatherHints consumer) {
consumer.accept(Items.COMPASS, comp);
}

@SubscribeEvent
public void onUpdate(PlayerTickEvent event) {
if(event.phase == Phase.START) {
Inventory inventory = event.player.getInventory();
for(int i = 0; i < inventory.getContainerSize(); i++) {
ItemStack stack = inventory.getItem(i);
if(stack.getItem() == Items.COMPASS)
CompassAngleGetter.tickCompass(event.player, stack);
else if(stack.getItem() == Items.CLOCK)
ClockTimeGetter.tickClock(stack);
}
@PlayEvent
public void onUpdate(ZPlayerTick.Start event) {
Inventory inventory = event.getPlayer().getInventory();
for(int i = 0; i < inventory.getContainerSize(); i++) {
ItemStack stack = inventory.getItem(i);
if(stack.getItem() == Items.COMPASS)
CompassAngleGetter.tickCompass(event.getPlayer(), stack);
else if(stack.getItem() == Items.CLOCK)
ClockTimeGetter.tickClock(stack);
}
}

@ZetaLoadModule(clientReplacement = true)
public static class Client extends CompassesWorkEverywhereModule {

@LoadEvent
public void clientSetup(ZClientSetup e) {
e.enqueueWork(() -> {
if(!enabled)
return;

if(enableCompassNerf || enableNether || enableEnd)
ItemProperties.register(Items.COMPASS, new ResourceLocation("angle"), new CompassAngleGetter.Impl());

if(enableClockNerf)
ItemProperties.register(Items.CLOCK, new ResourceLocation("time"), new ClockTimeGetter.Impl());
});
}

}

}
Loading

0 comments on commit 1709357

Please sign in to comment.