Search in sources :

Example 36 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project BedrockIfy by juancarloscp52.

the class LoadingScreenWidget method render.

/**
 * Renders the bedrockify loading screen.
 * @param matrices Current MatrixStack.
 * @param width window width
 * @param height window height
 * @param title Title of the loading screen.
 * @param message Message of the loading screen. Set to null to use a random tip.
 * @param progress Loading screen progress. Set to -1 is the screen has no progress bar.
 */
public void render(MatrixStack matrices, int width, int height, Text title, Text message, int progress) {
    // If the background cube map is disabled for other screens, manually render the cube map for the loading screen.
    if (!Bedrockify.getInstance().settings.isCubemapBackgroundEnabled())
        BedrockifyRotatingCubeMapRenderer.getInstance().render();
    MinecraftClient client = MinecraftClient.getInstance();
    renderLogo(matrices, width, height, client);
    renderLoadingWidget(matrices, width, height, client);
    TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
    textRenderer.draw(matrices, title, width - textRenderer.getWidth(title) / 2.0f, height - 9.0f / 2.0f - 32, 76 + (76 << 8) + (76 << 16));
    renderTextBody(matrices, width, height, message, textRenderer);
    if (progress >= 0) {
        renderLoadingBar(matrices, client, width, height, progress);
    }
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 37 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project ImmersivePortalsMod by qouteall.

the class MyNetworkClient method processRedirectedPacket.

private static void processRedirectedPacket(DimensionType dimension, Packet packet) {
    MinecraftClient mc = MinecraftClient.getInstance();
    mc.execute(() -> {
        ClientWorld packetWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(dimension);
        assert packetWorld != null;
        assert packetWorld.getChunkManager() instanceof MyClientChunkManager;
        ClientPlayNetworkHandler netHandler = ((IEClientWorld) packetWorld).getNetHandler();
        if ((netHandler).getWorld() != packetWorld) {
            ((IEClientPlayNetworkHandler) netHandler).setWorld(packetWorld);
            Helper.err("The world field of client net handler is wrong");
        }
        ClientWorld originalWorld = mc.world;
        // some packet handling may use mc.world so switch it
        mc.world = packetWorld;
        try {
            packet.apply(netHandler);
        } catch (Throwable e) {
            throw new IllegalStateException("handling packet in " + dimension, e);
        } finally {
            mc.world = originalWorld;
        }
    });
}
Also used : IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) IEClientPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEClientPlayNetworkHandler) MinecraftClient(net.minecraft.client.MinecraftClient) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) MyClientChunkManager(com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) IEClientPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEClientPlayNetworkHandler)

Example 38 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method setupCameraTransformation.

public static void setupCameraTransformation() {
    MinecraftClient mc = MinecraftClient.getInstance();
    // rendering post processing shader may change view port
    if (OFInterface.isShaders.getAsBoolean()) {
    // Shaders.setViewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
    } else {
        GlStateManager.viewport(0, 0, mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
    }
    ((IEGameRenderer) PortalRenderer.mc.gameRenderer).applyCameraTransformations_(partialTicks);
    Camera camera = PortalRenderer.mc.gameRenderer.getCamera();
    camera.update(PortalRenderer.mc.world, (Entity) (PortalRenderer.mc.getCameraEntity() == null ? PortalRenderer.mc.player : PortalRenderer.mc.getCameraEntity()), PortalRenderer.mc.options.perspective > 0, PortalRenderer.mc.options.perspective == 2, partialTicks);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Camera(net.minecraft.client.render.Camera) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer)

Example 39 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project ImmersivePortalsMod by qouteall.

the class MyRenderHelper method onTotalRenderEnd.

public static void onTotalRenderEnd() {
    MinecraftClient mc = MinecraftClient.getInstance();
    CGlobal.clientWorldLoader.getDimensionRenderHelper(mc.world.dimension.getType()).switchToMe();
    if (getRenderedPortalNum() != 0) {
        // recover chunk renderer dispatcher
        ((IEWorldRenderer) mc.worldRenderer).getChunkRenderDispatcher().updateCameraPosition(mc.cameraEntity.x, mc.cameraEntity.z);
    }
    Vec3d currCameraPos = mc.gameRenderer.getCamera().getPos();
    cameraPosDelta = currCameraPos.subtract(lastCameraPos);
    if (cameraPosDelta.lengthSquared() > 1) {
        cameraPosDelta = Vec3d.ZERO;
    }
    lastCameraPos = currCameraPos;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) Vec3d(net.minecraft.util.math.Vec3d)

Example 40 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project ImmersivePortalsMod by qouteall.

the class MOShaders method onInit.

// @Redirect(
// method = "loadShaderPack",
// at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/MinecraftClient;reloadResourcesConcurrently()Ljava/util/concurrent/CompletableFuture;"
// )
// )
// private static CompletableFuture<Void> redirectReloadResource(MinecraftClient minecraftClient) {
// if (!OFGlobal.shaderContextManager.isContextSwitched()) {
// return minecraftClient.reloadResourcesConcurrently();
// }
// else {
// return null;
// }
// }
@Inject(method = "init", at = @At("HEAD"))
private static void onInit(CallbackInfo ci) {
    MinecraftClient mc = MinecraftClient.getInstance();
    DimensionType currDimension = mc.world.dimension.getType();
    Helper.log("Shader init " + currDimension);
}
Also used : DimensionType(net.minecraft.world.dimension.DimensionType) MinecraftClient(net.minecraft.client.MinecraftClient) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3