forked from FabricMC/fabric
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"
|
||||
version = getSubprojectVersion(project, "0.1.0")
|
||||
version = getSubprojectVersion(project, "0.1.1")
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||
|
|
|
@ -66,15 +66,21 @@ 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(() -> {
|
||||
ContainerFactory<AbstractContainerScreen> factory = FACTORIES.get(identifier);
|
||||
if (factory == null) {
|
||||
LOGGER.error("No GUI factory found for {}!", identifier.toString());
|
||||
return;
|
||||
try {
|
||||
ContainerFactory<AbstractContainerScreen> factory = FACTORIES.get(identifier);
|
||||
if (factory == null) {
|
||||
LOGGER.error("No GUI factory found for {}!", identifier.toString());
|
||||
return;
|
||||
}
|
||||
AbstractContainerScreen gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
|
||||
packetContext.getPlayer().container = gui.getContainer();
|
||||
MinecraftClient.getInstance().openScreen(gui);
|
||||
} finally {
|
||||
packetByteBuf.release();
|
||||
}
|
||||
AbstractContainerScreen gui = factory.create(syncId, identifier, packetContext.getPlayer(), packetByteBuf);
|
||||
packetContext.getPlayer().container = gui.getContainer();
|
||||
MinecraftClient.getInstance().openScreen(gui);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue