diff options
author | syeyoung <cyong06@naver.com> | 2021-07-21 00:46:23 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-07-21 00:46:23 +0900 |
commit | 4850d1a1f795f625286b9a2058143f688265dc3d (patch) | |
tree | 5ed6a93797a12751aa86e22998a053422f7542c1 /src/main | |
parent | a6009e4aef3a8f8b641733d62034bf629afd7053 (diff) | |
download | Skyblock-Dungeons-Guide-4850d1a1f795f625286b9a2058143f688265dc3d.tar.gz Skyblock-Dungeons-Guide-4850d1a1f795f625286b9a2058143f688265dc3d.tar.bz2 Skyblock-Dungeons-Guide-4850d1a1f795f625286b9a2058143f688265dc3d.zip |
Window Update Event
Diffstat (limited to 'src/main')
4 files changed, 79 insertions, 4 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index 971d7ca9..904ff043 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -31,6 +31,7 @@ import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -68,6 +69,20 @@ public class FeatureListener { } } @SubscribeEvent + public void onWindowUpdate(WindowUpdateEvent windowUpdateEvent) { + try { + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnSkyblock()) return; + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof GuiUpdateListener) { + ((GuiUpdateListener) abstractFeature).onGuiUpdate(windowUpdateEvent); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + @SubscribeEvent public void onRender(RenderLivingEvent.Pre preRender) { try { SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java index 53eebd7b..b89a5fde 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java @@ -28,13 +28,12 @@ import kr.syeyoung.dungeonsguide.cosmetics.CustomPacketPlayerListItem; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import kr.syeyoung.dungeonsguide.events.PlayerListItemPacketEvent; import kr.syeyoung.dungeonsguide.events.TitleEvent; +import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import net.minecraft.client.Minecraft; import net.minecraft.network.Packet; import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.server.S04PacketEntityEquipment; -import net.minecraft.network.play.server.S38PacketPlayerListItem; -import net.minecraft.network.play.server.S45PacketTitle; +import net.minecraft.network.play.server.*; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; @@ -61,8 +60,10 @@ public class PacketListener extends ChannelDuplexHandler { if (packet instanceof S38PacketPlayerListItem) { packet = new CustomPacketPlayerListItem((S38PacketPlayerListItem) packet); } + if (packet instanceof S30PacketWindowItems || packet instanceof S2FPacketSetSlot) { + MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(packet instanceof S30PacketWindowItems ? (S30PacketWindowItems)packet : null , packet instanceof S2FPacketSetSlot ? (S2FPacketSetSlot)packet : null)); + } super.channelRead(ctx, packet); - } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java b/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java new file mode 100644 index 00000000..4c1b1150 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/events/WindowUpdateEvent.java @@ -0,0 +1,33 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.events; + +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraft.network.play.server.S45PacketTitle; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Data +@AllArgsConstructor +public class WindowUpdateEvent extends Event { + S30PacketWindowItems windowItems; + S2FPacketSetSlot packetSetSlot; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java new file mode 100644 index 00000000..a52baac7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiUpdateListener.java @@ -0,0 +1,26 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.listener; + +import kr.syeyoung.dungeonsguide.events.WindowUpdateEvent; +import net.minecraftforge.client.event.GuiScreenEvent; + +public interface GuiUpdateListener { + void onGuiUpdate(WindowUpdateEvent windowUpdateEvent); +} |