aboutsummaryrefslogtreecommitdiff
path: root/mod/src
diff options
context:
space:
mode:
authorsyeyoung <cyoung06@naver.com>2023-02-05 21:36:54 +0900
committersyeyoung <cyoung06@naver.com>2023-02-05 21:39:01 +0900
commitbe67be774fc50434ede11d1c29209d700c0f41e0 (patch)
treed66d37a913eb8def4e0ee9398ce20a54297972df /mod/src
parent5b6793dcd874c7b878447df5eadb873bb9513b88 (diff)
downloadSkyblock-Dungeons-Guide-be67be774fc50434ede11d1c29209d700c0f41e0.tar.gz
Skyblock-Dungeons-Guide-be67be774fc50434ede11d1c29209d700c0f41e0.tar.bz2
Skyblock-Dungeons-Guide-be67be774fc50434ede11d1c29209d700c0f41e0.zip
- Fixes most skytils incompatibility, fixes #295, fixes #296, fixes #297, fixes #298
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src')
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java1
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/annotations/EventHandlerRegistry.java3
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java24
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/WrappedPacket.java63
-rw-r--r--mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java2
5 files changed, 24 insertions, 69 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java
index 9686a855..86bded25 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/cosmetics/CustomNetworkPlayerInfo.java
@@ -92,6 +92,7 @@ public class CustomNetworkPlayerInfo extends NetworkPlayerInfo {
CosmeticData color=null;
for (ActiveCosmetic activeCosmetic : activeCosmetics) {
CosmeticData cosmeticData = DungeonsGuide.getDungeonsGuide().getCosmeticsManager().getCosmeticDataMap().get(activeCosmetic.getCosmeticData());
+ if (cosmeticData == null) continue;
if (cosmeticData.getCosmeticType().equals("color")) color = cosmeticData;
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/annotations/EventHandlerRegistry.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/annotations/EventHandlerRegistry.java
index b333ad79..7fde5290 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/annotations/EventHandlerRegistry.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/annotations/EventHandlerRegistry.java
@@ -123,8 +123,9 @@ public class EventHandlerRegistry {
for (InvocationTarget target : targetList) {
profiler.startSection(target.getTargetName());
try {
- if (target.condition == null || (target.condition.get() == Boolean.TRUE)) // it is safe to use this here.
+ if (target.condition == null || (target.condition.get() == Boolean.TRUE)) { // it is safe to use this here.
target.invokeSite.invoke(event);
+ }
} catch (Throwable e) {
logger.error("An error occurred while handling event: \nFeature = " + target.getFeature().getClass().getName(), e);
}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java
index ff077148..ab8c1ae9 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/PacketInjector.java
@@ -19,6 +19,7 @@
package kr.syeyoung.dungeonsguide.mod.events.listener;
import io.netty.channel.*;
+import kr.syeyoung.dungeonsguide.mod.events.impl.PacketProcessedEvent;
import kr.syeyoung.dungeonsguide.mod.events.impl.PlayerInteractEntityEvent;
import kr.syeyoung.dungeonsguide.mod.events.impl.RawPacketReceivedEvent;
import net.minecraft.client.Minecraft;
@@ -53,12 +54,26 @@ public class PacketInjector extends ChannelDuplexHandler {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Packet packet = (Packet) msg;
- if (targetedPackets.contains(msg.getClass())) {
- RawPacketReceivedEvent receivedEvent = new RawPacketReceivedEvent(packet);
- MinecraftForge.EVENT_BUS.post(receivedEvent);
- packet = new WrappedPacket(receivedEvent.packet);
+ boolean doStuff = targetedPackets.contains(msg.getClass());
+ try {
+ if (doStuff) {
+ RawPacketReceivedEvent receivedEvent = new RawPacketReceivedEvent(packet);
+ MinecraftForge.EVENT_BUS.post(receivedEvent);
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
}
+
+ // Hopefully this works? idk
+ if (doStuff)
+ Minecraft.getMinecraft().addScheduledTask(() -> {
+ MinecraftForge.EVENT_BUS.post(new PacketProcessedEvent.Pre(packet));
+ });
super.channelRead(ctx, packet);
+ if (doStuff)
+ Minecraft.getMinecraft().addScheduledTask(() -> {
+ MinecraftForge.EVENT_BUS.post(new PacketProcessedEvent.Post(packet));
+ });
}
@Override
@@ -71,7 +86,6 @@ public class PacketInjector extends ChannelDuplexHandler {
piee = new PlayerInteractEntityEvent(true, packet2.getEntityFromWorld(Minecraft.getMinecraft().theWorld));
else
piee = new PlayerInteractEntityEvent(false, ((C02PacketUseEntity) packet).getEntityFromWorld(Minecraft.getMinecraft().theWorld));
-
if (MinecraftForge.EVENT_BUS.post(piee)) return;
}
super.write(ctx, msg, promise);
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/WrappedPacket.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/WrappedPacket.java
deleted file mode 100644
index 5b2548b8..00000000
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/WrappedPacket.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod
- * Copyright (C) 2023 cyoung06 (syeyoung)
- *
- * 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.mod.events.listener;
-
-import kr.syeyoung.dungeonsguide.mod.events.impl.PacketProcessedEvent;
-import lombok.AllArgsConstructor;
-import lombok.RequiredArgsConstructor;
-import net.minecraft.client.Minecraft;
-import net.minecraft.network.Packet;
-import net.minecraft.network.PacketBuffer;
-import net.minecraft.network.play.INetHandlerPlayClient;
-import net.minecraftforge.common.MinecraftForge;
-
-import java.io.IOException;
-
-@RequiredArgsConstructor
-public class WrappedPacket implements Packet<INetHandlerPlayClient> {
- private final Packet<INetHandlerPlayClient> delegate;
- @Override
- public void readPacketData(PacketBuffer buf) throws IOException {
- delegate.readPacketData(buf);
- }
-
- @Override
- public void writePacketData(PacketBuffer buf) throws IOException {
- delegate.writePacketData(buf);
- }
-
- private INetHandlerPlayClient iNetHandlerPlayClient;
- private boolean processed = false;
- @Override
- public void processPacket(INetHandlerPlayClient handler) {
- if (processed) {
- delegate.processPacket(handler);
- }
- this.iNetHandlerPlayClient = handler;
- processed =true;
- // lmao
- Minecraft.getMinecraft().addScheduledTask(this::legitProcessPacket);
- }
-
- private void legitProcessPacket() {
- MinecraftForge.EVENT_BUS.post(new PacketProcessedEvent.Pre(delegate));
- delegate.processPacket(iNetHandlerPlayClient);
- MinecraftForge.EVENT_BUS.post(new PacketProcessedEvent.Post(delegate));
- }
-}
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
index c088fc2c..7fb6e0da 100644
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java
@@ -27,6 +27,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.ConstraintBox;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Rect;
import kr.syeyoung.dungeonsguide.mod.guiv2.primitive.Size;
import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext;
+import kr.syeyoung.dungeonsguide.mod.utils.GlStateUtils;
import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor;
import kr.syeyoung.dungeonsguide.mod.utils.cursor.GLCursors;
import lombok.Getter;
@@ -43,6 +44,7 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.io.IOException;
+import java.util.Map;
import static org.lwjgl.opengl.GL11.GL_GREATER;