diff options
author | syeyoung <cyougn06@naver.com> | 2022-01-31 23:39:50 +0900 |
---|---|---|
committer | syeyoung <cyougn06@naver.com> | 2022-01-31 23:39:50 +0900 |
commit | 2ed2473865ced32b3810de6fdd433fb017d247af (patch) | |
tree | 647af320d258a4a925ce80142795256bdbc24e69 /src/main/java/kr/syeyoung | |
parent | 8ef1a2bc1d3fc32882bc4739ef6876ac2c879ccd (diff) | |
download | Skyblock-Dungeons-Guide-2ed2473865ced32b3810de6fdd433fb017d247af.tar.gz Skyblock-Dungeons-Guide-2ed2473865ced32b3810de6fdd433fb017d247af.tar.bz2 Skyblock-Dungeons-Guide-2ed2473865ced32b3810de6fdd433fb017d247af.zip |
- Fix Custom Party List flickering and sometimes not displaying elements
- Fix Custom Party List displaying player count on "None" bedrock
Diffstat (limited to 'src/main/java/kr/syeyoung')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java | 31 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java | 20 |
2 files changed, 43 insertions, 8 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java index afb60168..759ecca9 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/PacketListener.java @@ -39,6 +39,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; +import java.util.Arrays; + @ChannelHandler.Sharable public class PacketListener extends ChannelDuplexHandler { private final SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); @@ -61,8 +63,11 @@ 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)); + if (packet instanceof S30PacketWindowItems) { + packet = new CustomWindowItems((S30PacketWindowItems) packet); + } + if (packet instanceof S2FPacketSetSlot) { + packet = new CustomSetSlot((S2FPacketSetSlot) packet); } if (packet instanceof S23PacketBlockChange) { packet = new SingleBlockChange((S23PacketBlockChange) packet); @@ -72,6 +77,28 @@ public class PacketListener extends ChannelDuplexHandler { super.channelRead(ctx, packet); } + private static class CustomWindowItems extends S30PacketWindowItems { + public CustomWindowItems(S30PacketWindowItems parent) { + super(parent.func_148911_c(), Arrays.asList(parent.getItemStacks())); + } + + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(this, null)); + } + } + private static class CustomSetSlot extends S2FPacketSetSlot { + public CustomSetSlot(S2FPacketSetSlot parent) { + super(parent.func_149175_c(), parent.func_149173_d(), parent.func_149174_e()); + } + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + MinecraftForge.EVENT_BUS.post(new WindowUpdateEvent(null, this)); + } + } + private static class SingleBlockChange extends S23PacketBlockChange { private S23PacketBlockChange old; public SingleBlockChange(S23PacketBlockChange blockChange) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java index 1def0528..7ccbdcf9 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/party/customgui/PanelPartyListElement.java @@ -63,20 +63,27 @@ public class PanelPartyListElement extends MPanel { private MTooltip mTooltip; + private ItemStack lastStack; @Override public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { GuiCustomPartyFinder guiCustomPartyFinder = panelPartyFinder.getGuiCustomPartyFinder(); if (guiCustomPartyFinder.getGuiChest() == null) return; Slot s = guiCustomPartyFinder.getGuiChest().inventorySlots.getSlot(slot); ItemStack itemStack = s.getStack(); - if (itemStack == null) return; - - + if (itemStack == null && lastStack == null) return; + if (itemStack != null) + lastStack = itemStack; + else + itemStack = lastStack; int color = RenderUtils.blendAlpha(0x141414, 0.0f); String note = ""; + boolean notfound = false; boolean cantjoin = false; - if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) cantjoin = true; + if (itemStack.getItem() == Item.getItemFromBlock(Blocks.bedrock)) { + cantjoin = true; + notfound = true; + } int minClass = -1, minDungeon = -1; int pplIn = 0; Set<String> dungeonClasses = new HashSet<>(); @@ -159,14 +166,15 @@ public class PanelPartyListElement extends MPanel { name = name.substring(0, name.indexOf("'")); fr.drawString(name, 0,0,-1); - note = "§7("+pplIn+") §f"+note; + if (!notfound) + note = "§7("+pplIn+") §f"+note; fr.drawString(note, fr.getStringWidth("AAAAAAAAAAAAAAAA")+5, 0,-1); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); String sideNote = ""; if (minClass != -1) sideNote += "§7CLv ≥§b"+minClass+" "; if (minDungeon != -1) sideNote += "§7DLv ≥§b"+minDungeon+" "; - if (cantjoin) sideNote = "§cCan't join"; + if (cantjoin && !notfound) sideNote = "§cCan't join"; sideNote = sideNote.trim(); GlStateManager.translate(getBounds().width,(32 - 2*fr.FONT_HEIGHT)/2,0); |