Search in sources :

Example 76 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project Biome-Makeover by Lemonszz.

the class ItemGroupTabWidget method renderButton.

public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
    MinecraftClient minecraftClient = MinecraftClient.getInstance();
    minecraftClient.getTextureManager().bindTexture(TEXTURE);
    RenderSystem.color4f(1.0F, 1.0F, 1.0F, this.alpha);
    int i = this.getYImage(this.isHovered());
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
    this.drawTexture(matrixStack, this.x, this.y, 0, i * height, this.width, this.height);
    this.renderBg(matrixStack, minecraftClient, mouseX, mouseY);
    minecraftClient.getItemRenderer().renderInGui(tab.getIcon(), this.x + 3, this.y + 3);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 77 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project EarthMCEssentials by EarthMC-Stats.

the class EarthMCAPI method getNearby.

public static CompletableFuture<JsonArray> getNearby(int xBlocks, int zBlocks) {
    return CompletableFuture.supplyAsync(() -> {
        try {
            MinecraftClient client = MinecraftClient.getInstance();
            ClientPlayerEntity player = client.player;
            if (player != null) {
                if (!player.getEntityWorld().getDimension().isBedWorking())
                    return new JsonArray();
                JsonArray array = (JsonArray) new JsonParser().parse(getURL(config.api.main.domain() + config.api.routes.nearby + (int) player.getX() + "/" + (int) player.getZ() + "/" + xBlocks + "/" + zBlocks));
                for (int i = 0; i < array.size(); i++) {
                    JsonObject currentObj = (JsonObject) array.get(i);
                    if (currentObj.get("name").getAsString().equals(client.player.getName().asString()))
                        array.remove(i);
                }
                return array;
            } else
                return EarthMCEssentials.instance().getNearbyPlayers();
        } catch (APIException e) {
            MsgUtils.sendDebugMessage(e.getMessage(), e);
            return EarthMCEssentials.instance().getNearbyPlayers();
        }
    });
}
Also used : APIException(net.emc.emce.object.exception.APIException) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 78 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.

the class IsometricRenderPresets method setupBlockEntityRender.

public static void setupBlockEntityRender(IsometricRenderScreen screen, @NotNull BlockEntity entity) {
    final MinecraftClient client = MinecraftClient.getInstance();
    final Identifier blockId = Registry.BLOCK.getId(entity.getCachedState().getBlock());
    screen.setup((matrices, vertexConsumerProvider, tickDelta) -> {
        matrices.push();
        matrices.translate(-0.5, 0, -0.5);
        client.getBlockRenderManager().renderBlockAsEntity(entity.getCachedState(), matrices, vertexConsumerProvider, 15728880, OverlayTexture.DEFAULT_UV);
        if (BlockEntityRenderDispatcher.INSTANCE.get(entity) != null) {
            BlockEntityRenderDispatcher.INSTANCE.get(entity).render(entity, tickDelta, matrices, vertexConsumerProvider, 15728880, OverlayTexture.DEFAULT_UV);
        }
        double xOffset = client.player.getX() % 1d;
        double zOffset = client.player.getZ() % 1d;
        if (xOffset < 0)
            xOffset += 1;
        if (zOffset < 0)
            zOffset += 1;
        matrices.translate(xOffset, 1.65 + client.player.getY() % 1d, zOffset);
        client.particleManager.renderParticles(matrices, (VertexConsumerProvider.Immediate) vertexConsumerProvider, client.gameRenderer.getLightmapTextureManager(), getParticleCamera(), tickDelta);
        matrices.pop();
    }, blockId.getNamespace() + "/blocks/" + blockId.getPath());
    screen.setTickCallback(() -> {
        if (entity instanceof Tickable) {
            ((Tickable) entity).tick();
        }
        if (client.world.random.nextDouble() < 0.150) {
            entity.getCachedState().getBlock().randomDisplayTick(entity.getCachedState(), client.world, client.player.getBlockPos(), client.world.random);
        }
    });
}
Also used : Identifier(net.minecraft.util.Identifier) Tickable(net.minecraft.util.Tickable) MinecraftClient(net.minecraft.client.MinecraftClient) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 79 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeEntity.

private static int executeEntity(FabricClientCommandSource source, Identifier entityType, CompoundTag entityTag) {
    final MinecraftClient client = MinecraftClient.getInstance();
    IsometricRenderScreen screen = new IsometricRenderScreen();
    entityTag.putString("id", entityType.toString());
    Entity entity = EntityType.loadEntityWithPassengers(entityTag, client.world, Function.identity());
    entity.updatePosition(client.player.getX(), client.player.getY(), client.player.getZ());
    entity.setWorld(client.world);
    if (entity instanceof MobEntity) {
        ((MobEntity) entity).setPersistent();
    }
    IsometricRenderPresets.setupEntityRender(screen, entity);
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) BlockEntity(net.minecraft.block.entity.BlockEntity) MobEntity(net.minecraft.entity.mob.MobEntity) Entity(net.minecraft.entity.Entity) BlockWithEntity(net.minecraft.block.BlockWithEntity) MinecraftClient(net.minecraft.client.MinecraftClient) MobEntity(net.minecraft.entity.mob.MobEntity)

Example 80 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.

the class IsoRenderCommand method executeItem.

private static int executeItem(FabricClientCommandSource source, ItemStack stack) {
    MinecraftClient client = MinecraftClient.getInstance();
    IsometricRenderScreen screen = new IsometricRenderScreen();
    IsometricRenderPresets.setupItemStackRender(screen, stack);
    IsometricRenderHelper.scheduleScreen(screen);
    return 0;
}
Also used : IsometricRenderScreen(com.glisco.isometricrenders.client.gui.IsometricRenderScreen) AreaIsometricRenderScreen(com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen) MinecraftClient(net.minecraft.client.MinecraftClient)

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