mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 17:46:25 -05:00
fix custom containers not working with new fabric-networking
This commit is contained in:
parent
d36c5fcf8e
commit
b02b567de3
2 changed files with 14 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-containers-v0"
|
archivesBaseName = "fabric-containers-v0"
|
||||||
version = getSubprojectVersion(project, "0.1.0")
|
version = getSubprojectVersion(project, "0.1.1")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -66,7 +66,10 @@ public class ScreenProviderRegistryImpl implements ScreenProviderRegistry {
|
||||||
ClientSidePacketRegistry.INSTANCE.register(PacketTypes.OPEN_CONTAINER, (packetContext, packetByteBuf) -> {
|
ClientSidePacketRegistry.INSTANCE.register(PacketTypes.OPEN_CONTAINER, (packetContext, packetByteBuf) -> {
|
||||||
Identifier identifier = packetByteBuf.readIdentifier();
|
Identifier identifier = packetByteBuf.readIdentifier();
|
||||||
int syncId = packetByteBuf.readUnsignedByte();
|
int syncId = packetByteBuf.readUnsignedByte();
|
||||||
|
packetByteBuf.retain();
|
||||||
|
|
||||||
MinecraftClient.getInstance().execute(() -> {
|
MinecraftClient.getInstance().execute(() -> {
|
||||||
|
try {
|
||||||
ContainerFactory<AbstractContainerScreen> factory = FACTORIES.get(identifier);
|
ContainerFactory<AbstractContainerScreen> factory = FACTORIES.get(identifier);
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
LOGGER.error("No GUI factory found for {}!", identifier.toString());
|
LOGGER.error("No GUI factory found for {}!", identifier.toString());
|
||||||
|
@ -75,6 +78,9 @@ public class ScreenProviderRegistryImpl implements ScreenProviderRegistry {
|
||||||
AbstractContainerScreen gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
|
AbstractContainerScreen gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
|
||||||
packetContext.getPlayer().container = gui.getContainer();
|
packetContext.getPlayer().container = gui.getContainer();
|
||||||
MinecraftClient.getInstance().openScreen(gui);
|
MinecraftClient.getInstance().openScreen(gui);
|
||||||
|
} finally {
|
||||||
|
packetByteBuf.release();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue