Search in sources :

Example 1 with ModularUIGui

use of gregtech.api.gui.impl.ModularUIGui in project GregTech by GregTechCE.

the class UIFactory method initClientUI.

@SideOnly(Side.CLIENT)
public final void initClientUI(PacketBuffer serializedHolder, int windowId) {
    E holder = readHolderFromSyncData(serializedHolder);
    Minecraft minecraft = Minecraft.getMinecraft();
    EntityPlayerSP entityPlayer = minecraft.player;
    ModularUI<E> uiTemplate = createUITemplate(holder, entityPlayer);
    uiTemplate.initWidgets();
    minecraft.addScheduledTask(() -> {
        minecraft.displayGuiScreen(new ModularUIGui(uiTemplate));
        entityPlayer.openContainer.windowId = windowId;
    });
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) ModularUIGui(gregtech.api.gui.impl.ModularUIGui) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with ModularUIGui

use of gregtech.api.gui.impl.ModularUIGui in project GregTech by GregTechCE.

the class UIFactory method initClientUI.

@SideOnly(Side.CLIENT)
public final void initClientUI(PacketBuffer serializedHolder, int windowId, List<PacketUIWidgetUpdate> initialWidgetUpdates) {
    E holder = readHolderFromSyncData(serializedHolder);
    Minecraft minecraft = Minecraft.getMinecraft();
    EntityPlayerSP entityPlayer = minecraft.player;
    ModularUI uiTemplate = createUITemplate(holder, entityPlayer);
    uiTemplate.initWidgets();
    ModularUIGui modularUIGui = new ModularUIGui(uiTemplate);
    modularUIGui.inventorySlots.windowId = windowId;
    for (PacketUIWidgetUpdate packet : initialWidgetUpdates) {
        modularUIGui.handleWidgetUpdate(packet);
    }
    minecraft.addScheduledTask(() -> {
        minecraft.displayGuiScreen(modularUIGui);
        minecraft.player.openContainer.windowId = windowId;
    });
}
Also used : PacketUIWidgetUpdate(gregtech.api.net.PacketUIWidgetUpdate) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) ModularUIGui(gregtech.api.gui.impl.ModularUIGui) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with ModularUIGui

use of gregtech.api.gui.impl.ModularUIGui in project GregTech by GregTechCE.

the class NetworkHandler method initClient.

@SideOnly(Side.CLIENT)
private static void initClient() {
    registerClientExecutor(PacketUIOpen.class, (packet, handler) -> {
        UIFactory<?> uiFactory = UIFactory.FACTORY_REGISTRY.getObjectById(packet.uiFactoryId);
        if (uiFactory == null) {
            GTLog.logger.warn("Couldn't find UI Factory with id '{}'", packet.uiFactoryId);
        } else {
            uiFactory.initClientUI(packet.serializedHolder, packet.windowId, packet.initialWidgetUpdates);
        }
    });
    registerClientExecutor(PacketUIWidgetUpdate.class, (packet, handler) -> {
        GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
        if (currentScreen instanceof ModularUIGui) {
            ((ModularUIGui) currentScreen).handleWidgetUpdate(packet);
        }
    });
    registerClientExecutor(PacketBlockParticle.class, (packet, handler) -> {
        World world = Minecraft.getMinecraft().world;
        IBlockState blockState = world.getBlockState(packet.blockPos);
        ParticleManager particleManager = Minecraft.getMinecraft().effectRenderer;
        ((ICustomParticleBlock) blockState.getBlock()).handleCustomParticle(world, packet.blockPos, particleManager, packet.entityPos, packet.particlesAmount);
    });
    registerClientExecutor(PacketClipboard.class, (packet, handler) -> {
        ClipboardUtil.copyToClipboard(packet.text);
    });
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ICustomParticleBlock(gregtech.api.block.ICustomParticleBlock) GuiScreen(net.minecraft.client.gui.GuiScreen) ParticleManager(net.minecraft.client.particle.ParticleManager) World(net.minecraft.world.World) ModularUIGui(gregtech.api.gui.impl.ModularUIGui) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ModularUIGui (gregtech.api.gui.impl.ModularUIGui)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 ICustomParticleBlock (gregtech.api.block.ICustomParticleBlock)1 PacketUIWidgetUpdate (gregtech.api.net.PacketUIWidgetUpdate)1 IBlockState (net.minecraft.block.state.IBlockState)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 ParticleManager (net.minecraft.client.particle.ParticleManager)1 World (net.minecraft.world.World)1