-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: changing side buttons doesn't work on Forge
- Loading branch information
Showing
3 changed files
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
...m/refinedmods/refinedstorage2/platform/forge/support/packet/c2s/PropertyChangePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
package com.refinedmods.refinedstorage2.platform.forge.support.packet.c2s; | ||
|
||
import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseContainerMenu; | ||
import com.refinedmods.refinedstorage2.platform.common.support.packet.PacketIds; | ||
|
||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.neoforge.network.handling.PlayPayloadContext; | ||
|
||
public record PropertyChangePacket(ResourceLocation id, int value) implements CustomPacketPayload { | ||
public record PropertyChangePacket(ResourceLocation propertyId, int value) implements CustomPacketPayload { | ||
public static PropertyChangePacket decode(final FriendlyByteBuf buf) { | ||
return new PropertyChangePacket(buf.readResourceLocation(), buf.readInt()); | ||
} | ||
|
||
public static void handle(final PropertyChangePacket packet, final PlayPayloadContext ctx) { | ||
ctx.player().ifPresent(player -> ctx.workHandler().submitAsync(() -> { | ||
if (player.containerMenu instanceof AbstractBaseContainerMenu menu) { | ||
menu.receivePropertyChangeFromClient(packet.id, packet.value); | ||
menu.receivePropertyChangeFromClient(packet.propertyId, packet.value); | ||
} | ||
})); | ||
} | ||
|
||
@Override | ||
public void write(final FriendlyByteBuf buf) { | ||
buf.writeResourceLocation(id); | ||
buf.writeResourceLocation(propertyId); | ||
buf.writeInt(value); | ||
} | ||
|
||
@Override | ||
public ResourceLocation id() { | ||
return PacketIds.PROPERTY_CHANGE; | ||
} | ||
} |