use of net.minecraft.client.MinecraftClient in project ImmersivePortalsMod by qouteall.
the class OFInterfaceInitializer method init.
public static void init() {
Validate.isTrue(OFInterface.isOptifinePresent);
OFInterface.isShaders = Config::isShaders;
OFInterface.isShadowPass = () -> Config.isShaders() && Shaders.isShadowPass;
OFInterface.bindToShaderFrameBuffer = () -> {
EXTFramebufferObject.glBindFramebufferEXT(36160, OFGlobal.getDfb.get());
GlStateManager.viewport(0, 0, Shaders.renderWidth, Shaders.renderHeight);
};
OFInterface.beforeRenderCenter = (partialTicks) -> {
if (Config.isShaders()) {
MinecraftClient mc = MinecraftClient.getInstance();
Shaders.activeProgram = Shaders.ProgramNone;
Shaders.beginRender(mc, mc.gameRenderer.getCamera(), partialTicks, 0);
}
};
OFInterface.afterRenderCenter = () -> Shaders.activeProgram = Shaders.ProgramNone;
OFInterface.resetViewport = () -> {
if (OFInterface.isShaders.getAsBoolean()) {
GlStateManager.viewport(0, 0, Shaders.renderWidth, Shaders.renderHeight);
}
};
OFInterface.onPlayerTraveled = (fromDimension1, toDimension1) -> {
if (OFInterface.isShaders.getAsBoolean()) {
OFGlobal.shaderContextManager.onPlayerTraveled(fromDimension1, toDimension1);
}
};
OFInterface.shouldDisableFog = () -> {
GameRenderer gameRenderer = MinecraftClient.getInstance().gameRenderer;
if (gameRenderer_fogStandard == null) {
try {
gameRenderer_fogStandard = GameRenderer.class.getDeclaredField("fogStandard");
} catch (NoSuchFieldException e) {
throw new IllegalStateException(e);
}
}
try {
boolean fogStandard = gameRenderer_fogStandard.getBoolean(gameRenderer);
return Config.isFogOff() && fogStandard;
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
}
};
OFInterface.createNewRenderInfosNormal = newWorldRenderer1 -> {
/**
*{@link WorldRenderer#chunkInfos}
*/
// in vanilla it will create new chunkInfos object every frame
// but with optifine it will always use one object
// we need to switch chunkInfos correctly
// if we do not put it a new object, it will clear the original chunkInfos
((IEOFWorldRenderer) newWorldRenderer1).createNewRenderInfosNormal();
};
OFInterface.initShaderCullingManager = ShaderCullingManager::init;
}
use of net.minecraft.client.MinecraftClient in project quilt-standard-libraries by QuiltMC.
the class ClientCommandInternals method executeCommand.
/**
* Executes a client-sided command from a message.
*
* @param message the command message
*
* @return {@code true} if the message was executed as a command client-side (and therefore should not be sent to the
* server), {@code false} otherwise
*/
public static boolean executeCommand(String message) {
if (message.isEmpty()) {
// Nothing to process
return false;
}
if (message.charAt(0) != PREFIX) {
// Incorrect prefix, won't execute anything.
return false;
}
MinecraftClient client = MinecraftClient.getInstance();
// The interface is implemented on ClientCommandSource with a mixin.
// noinspection ConstantConditions
QuiltClientCommandSource commandSource = (QuiltClientCommandSource) client.getNetworkHandler().getCommandSource();
client.getProfiler().push(message);
try {
// Only run client commands if there are no matching server-side commands.
String command = message.substring(1);
CommandDispatcher<CommandSource> serverDispatcher = client.getNetworkHandler().getCommandDispatcher();
ParseResults<CommandSource> serverResults = serverDispatcher.parse(command, client.getNetworkHandler().getCommandSource());
if (serverResults.getReader().canRead() || isCommandInvalidOrDummy(serverResults)) {
DISPATCHER.execute(command, commandSource);
return true;
} else {
return false;
}
} catch (CommandSyntaxException e) {
boolean ignored = shouldIgnore(e.getType());
if (ignored) {
LOGGER.debug("Syntax exception for client-side command '{}'", message, e);
} else {
LOGGER.warn("Syntax exception for client-side command '{}'", message, e);
}
if (ignored) {
return false;
}
commandSource.sendError(getErrorMessage(e));
return true;
} catch (CommandException e) {
LOGGER.warn("Error while executing client-side command '{}'", message, e);
commandSource.sendError(e.getTextMessage());
return true;
} catch (RuntimeException e) {
LOGGER.warn("Error while executing client-side command '{}'", message, e);
commandSource.sendError(Text.of(e.getMessage()));
return true;
} finally {
client.getProfiler().pop();
}
}
use of net.minecraft.client.MinecraftClient in project friends-and-foes by Faboslav.
the class MoobloomFlowerFeatureRenderer method render.
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, T moobloomEntity, float f, float g, float h, float j, float k, float l) {
if (!moobloomEntity.isBaby() && !moobloomEntity.isInvisible()) {
BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
BlockState blockState = ModBlocks.BUTTERCUP.get().getDefaultState();
int overlay = LivingEntityRenderer.getOverlay(moobloomEntity, 0.0F);
MinecraftClient minecraftClient = MinecraftClient.getInstance();
boolean renderAsModel = minecraftClient.hasOutline(moobloomEntity) && moobloomEntity.isInvisible();
BakedModel bakedModel = blockRenderManager.getModel(blockState);
// Head
matrixStack.push();
this.getContextModel().getHead().rotate(matrixStack);
matrixStack.translate(0.09D, -0.6D, -0.185D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
// Body
matrixStack.push();
matrixStack.translate(0.22D, -0.28D, -0.06D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
matrixStack.push();
matrixStack.translate(-0.2D, -0.22D, 0.01D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
matrixStack.push();
matrixStack.translate(0.03D, -0.28D, 0.47D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
}
}
use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.
the class IsoRenderCommand method executeBlockTarget.
private static int executeBlockTarget(FabricClientCommandSource source) {
final MinecraftClient client = MinecraftClient.getInstance();
IsometricRenderScreen screen = new IsometricRenderScreen();
if (client.crosshairTarget.getType() != HitResult.Type.BLOCK) {
source.sendError(Text.of("You're not looking at a block"));
return 0;
}
final BlockPos hitPos = ((BlockHitResult) client.crosshairTarget).getBlockPos();
BlockState state = client.world.getBlockState(hitPos);
BlockEntity be = null;
if (state.getBlock() instanceof BlockWithEntity) {
CompoundTag tag = client.world.getBlockEntity(hitPos).toTag(new CompoundTag());
be = ((BlockWithEntity) state.getBlock()).createBlockEntity(client.world);
((BlockEntityAccessor) be).setCachedState(state);
be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
CompoundTag copyTag = tag.copy();
copyTag.putInt("x", 0);
copyTag.putInt("y", 0);
copyTag.putInt("z", 0);
be.fromTag(be.getCachedState(), copyTag);
be.setLocation(client.world, MinecraftClient.getInstance().player.getBlockPos());
}
if (be != null) {
IsometricRenderPresets.setupBlockEntityRender(screen, be);
} else {
IsometricRenderPresets.setupBlockStateRender(screen, state);
}
IsometricRenderHelper.scheduleScreen(screen);
return 0;
}
use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.
the class IsometricRendersClient method onInitializeClient.
@Override
public void onInitializeClient() {
IsoRenderCommand.register(ClientCommandManager.DISPATCHER);
ImageExporter.init();
HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> {
final MinecraftClient client = MinecraftClient.getInstance();
if (ImageExporter.getJobCount() < 1 || client.currentScreen != null)
return;
DrawableHelper.fill(matrixStack, 20, 20, 140, 60, 0x90000000);
client.textRenderer.draw(matrixStack, ImageExporter.getProgressBarText(), 30, 30, 0xFFFFFF);
RenderScreen.drawExportProgressBar(matrixStack, 30, 45, 100, 50, 10);
});
}
Aggregations