diff options
author | syeyoung <cyong06@naver.com> | 2021-01-04 12:48:13 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-04 12:48:13 +0900 |
commit | c9f71d77a5912a70546d6a0950d7f8c2bb4c89db (patch) | |
tree | 178b888f877b489d20bef311662e9b15a023c6d5 /src/main/java | |
parent | ec76162b0017cbfb546038e4d55a1f062d99412a (diff) | |
download | Skyblock-Dungeons-Guide-c9f71d77a5912a70546d6a0950d7f8c2bb4c89db.tar.gz Skyblock-Dungeons-Guide-c9f71d77a5912a70546d6a0950d7f8c2bb4c89db.tar.bz2 Skyblock-Dungeons-Guide-c9f71d77a5912a70546d6a0950d7f8c2bb4c89db.zip |
spirit boots, some fixes
Diffstat (limited to 'src/main/java')
7 files changed, 130 insertions, 9 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/e.java b/src/main/java/kr/syeyoung/dungeonsguide/e.java index 1d7f78f7..7e614758 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/e.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/e.java @@ -5,6 +5,7 @@ import kr.syeyoung.dungeonsguide.config.Config; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.eventlistener.DungeonListener; import kr.syeyoung.dungeonsguide.eventlistener.FeatureListener; +import kr.syeyoung.dungeonsguide.eventlistener.PacketListener; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.AhUtils; import lombok.Getter; @@ -56,6 +57,7 @@ public class e implements c { ClientCommandHandler.instance.registerCommand(commandDungeonsGuide = new CommandDungeonsGuide()); MinecraftForge.EVENT_BUS.register(commandDungeonsGuide); MinecraftForge.EVENT_BUS.register(new FeatureListener()); + MinecraftForge.EVENT_BUS.register(new PacketListener()); AhUtils.registerTimer(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java new file mode 100644 index 00000000..0a7ce483 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java @@ -0,0 +1,59 @@ +package kr.syeyoung.dungeonsguide.eventlistener; + +import io.netty.channel.ChannelDuplexHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.network.FMLNetworkEvent; + +import java.lang.reflect.Field; + +public class PacketListener extends ChannelDuplexHandler { + private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus();; + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + Packet packet = (Packet) msg; + if (skyblockStatus.isOnSkyblock() + && msg instanceof S04PacketEntityEquipment + && FeatureRegistry.FIX_SPIRIT_BOOTS.isEnabled()) { // Inventory packet name + S04PacketEntityEquipment packet2 = (S04PacketEntityEquipment) msg; + if (packet2.getEntityID() == Minecraft.getMinecraft().thePlayer.getEntityId()) { + packet2 = new S04PacketEntityEquipment(packet2.getEntityID(), packet2.getEquipmentSlot() + 1, packet2.getItemStack()); + packet = packet2; + } + } + super.channelRead(ctx, packet); + } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { +// if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && msg instanceof Packet && msg.getClass().getName().endsWith("C02PacketUseEntity")) { +// Minecraft mc = Minecraft.getMinecraft(); +// C02PacketUseEntity packet = (C02PacketUseEntity) msg; +// Entity entityHit = packet.getEntityFromWorld(mc.theWorld); +// if (entityHit instanceof EntityItemFrame) { +// EntityItemFrame itemFrame = (EntityItemFrame) entityHit; +// ItemStack item = itemFrame.getDisplayedItem(); +// if (item != null && item.getItem() == Items.arrow) { +// BlockPos blockPos = Utils.getBlockUnderItemFrame(itemFrame); +// if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) { +// return; +// } +// } +// } +// } + + super.write(ctx, msg, promise); + } + + @SubscribeEvent + public void onServerConnect(FMLNetworkEvent.ClientConnectedToServerEvent event) { + event.manager.channel().pipeline().addBefore("packet_handler", "dg_packet_handler", this); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 09bb1511..c5b9daa1 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -1,9 +1,6 @@ package kr.syeyoung.dungeonsguide.features; -import kr.syeyoung.dungeonsguide.features.impl.FeatureCooldownCounter; -import kr.syeyoung.dungeonsguide.features.impl.FeatureInstaCloseChest; -import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipDungeonStat; -import kr.syeyoung.dungeonsguide.features.impl.FeatureTooltipPrice; +import kr.syeyoung.dungeonsguide.features.impl.*; import lombok.Getter; import java.util.ArrayList; @@ -53,6 +50,8 @@ public class FeatureRegistry { public static final SimpleFeature DEBUG = register(new SimpleFeature("hidden", "Debug", "Toggles debug mode", "debug", false)); - public static final FeatureCooldownCounter QOL_COOLDOWN = register(new FeatureCooldownCounter()); - public static final FeatureInstaCloseChest QOL_INSTACLOSE = register(new FeatureInstaCloseChest()); + public static final FeatureCooldownCounter HUD_COOLDOWN = register(new FeatureCooldownCounter()); + public static final FeatureInstaCloseChest DUNGEON_INSTACLOSE = register(new FeatureInstaCloseChest()); + public static final FeatureBoxSkelemaster DUNGEON_BOXSKELEMASTER = register(new FeatureBoxSkelemaster()); + public static final SimpleFeature FIX_SPIRIT_BOOTS = register(new SimpleFeature("fixes", "Spirit Boots Fixer", "Fix Spirit boots messing up with inventory", "fixes.spirit", true)); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureBoxSkelemaster.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureBoxSkelemaster.java new file mode 100644 index 00000000..962e9350 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureBoxSkelemaster.java @@ -0,0 +1,51 @@ +package kr.syeyoung.dungeonsguide.features.impl; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.List; + + +public class FeatureBoxSkelemaster extends SimpleFeature implements WorldRenderListener { + public FeatureBoxSkelemaster() { + super("Dungeon", "Box Skeleton Masters", "Box skeleton masters in dungeons", "dungeon.skeletonmasterbox", true); + parameters.put("radius", new FeatureParameter<Integer>("radius", "Highlight Radius", "The maximum distance between player and skeletonmaster to be boxed", 20, "integer")); + parameters.put("color", new FeatureParameter<Color>("color", "Highlight Color", "Highlight Color of Skeleton master", Color.red, "color")); + } + + + private SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; + + final BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + int val = this.<Integer>getParameter("radius").getValue(); + final int sq = val * val; + + List<EntityArmorStand> skeletonList = Minecraft.getMinecraft().theWorld.getEntities(EntityArmorStand.class, new Predicate<EntityArmorStand>() { + @Override + public boolean apply(@Nullable EntityArmorStand input) { + if (player.distanceSq(input.getPosition()) > sq) return false; + return input.getName().contains("Skeleton Master"); + } + }); + Color c = this.<Color>getParameter("color").getValue(); + Color real = new Color(c.getRGB() & 0xFFFFFF | 0x44000000, true); + for (EntityArmorStand entitySkeleton : skeletonList) { + RenderUtils.highlightBox(entitySkeleton, real, partialTicks, false); + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java index dcf46281..276dfe3f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -13,7 +13,7 @@ import java.awt.*; public class FeatureCooldownCounter extends GuiFeature implements TickListener { public FeatureCooldownCounter() { - super("QoL", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); + super("HUD", "Dungeon Cooldown Counter", "Counts 10 seconds after leaving dungeon", "qol.cooldown", true, getFontRenderer().getStringWidth("Cooldown: 10s "), getFontRenderer().FONT_HEIGHT); parameters.put("color", new FeatureParameter<Color>("color", "Color", "Color of text", Color.white, "color")); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java index 33d2c9eb..f8069d73 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java @@ -26,7 +26,7 @@ import java.util.TreeSet; public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenListener, TickListener { public FeatureInstaCloseChest() { - super("QoL", "Auto-Close Secret Chest", "Automatically closes Secret Chest as soon as you open it\nCan put item price threshold by clicking edit", "qol.autoclose", false); + super("Dungeon", "Auto-Close Secret Chest", "Automatically closes Secret Chest as soon as you open it\nCan put item price threshold by clicking edit", "qol.autoclose", false); parameters.put("threshold", new FeatureParameter<Integer>("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer")); } @@ -40,7 +40,9 @@ public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenList if (!(event.gui instanceof GuiChest)) return; ContainerChest ch = (ContainerChest) ((GuiChest)event.gui).inventorySlots; - if (!"container.chest".equals(ch.getLowerChestInventory().getName())) return; + System.out.println(ch.getLowerChestInventory().getName()); + if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) + || "Chest".equals(ch.getLowerChestInventory().getName()))) return; check = true; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java new file mode 100644 index 00000000..42974d5b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/GuiPostRenderListener.java @@ -0,0 +1,8 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; + +public interface GuiPostRenderListener { + void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered); +} |