fix custom containers not working with new fabric-networking

This commit is contained in:
asie 2019-05-24 21:54:43 +02:00
parent d36c5fcf8e
commit b02b567de3
2 changed files with 14 additions and 8 deletions

View file

@ -1,5 +1,5 @@
archivesBaseName = "fabric-containers-v0"
version = getSubprojectVersion(project, "0.1.0")
version = getSubprojectVersion(project, "0.1.1")
dependencies {
compile project(path: ':fabric-api-base', configuration: 'dev')

View file

@ -66,7 +66,10 @@ public class ScreenProviderRegistryImpl implements ScreenProviderRegistry {
ClientSidePacketRegistry.INSTANCE.register(PacketTypes.OPEN_CONTAINER, (packetContext, packetByteBuf) -> {
Identifier identifier = packetByteBuf.readIdentifier();
int syncId = packetByteBuf.readUnsignedByte();
packetByteBuf.retain();
MinecraftClient.getInstance().execute(() -> {
try {
ContainerFactory<AbstractContainerScreen> factory = FACTORIES.get(identifier);
if (factory == null) {
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);
packetContext.getPlayer().container = gui.getContainer();
MinecraftClient.getInstance().openScreen(gui);
} finally {
packetByteBuf.release();
}
});
});
}