Skip to content

Commit

Permalink
Update follow button (#634)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Maya <[email protected]>
  • Loading branch information
3 people authored Dec 28, 2024
1 parent d7ae01f commit 6f36df1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ public void onContainerClosed(final EntityPlayer player) {
}
}

public void sendUpdateFollowPacket(List<String> playersFollowingCurrentCraft) {
NBTTagCompound nbttc = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();

if (playersFollowingCurrentCraft != null) {
for (String name : playersFollowingCurrentCraft) {
tagList.appendTag(new NBTTagString(name));
}
}
nbttc.setTag("playNameList", tagList);

for (final Object g : this.crafters) {
if (g instanceof EntityPlayerMP epmp) {
try {
NetworkHandler.instance.sendTo(new PacketCompressedNBT(nbttc), epmp);
} catch (final IOException e) {
// :P
}
}
}
}

@Override
public void detectAndSendChanges() {
if (Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import appeng.api.util.IInterfaceViewable;
import appeng.api.util.WorldCoord;
import appeng.container.ContainerNull;
import appeng.container.implementations.ContainerCraftingCPU;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
Expand Down Expand Up @@ -1572,6 +1573,13 @@ public void togglePlayerFollowStatus(final String name) {
} else {
this.playersFollowingCurrentCraft.add(name);
}

final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.getListeners();
while (i.hasNext()) {
if (i.next().getKey() instanceof ContainerCraftingCPU cccpu) {
cccpu.sendUpdateFollowPacket(playersFollowingCurrentCraft);
}
}
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit 6f36df1

Please sign in to comment.