use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.
the class IsometricRenderPresets method setupBlockStateRender.
public static void setupBlockStateRender(IsometricRenderScreen screen, @NotNull BlockState state) {
final MinecraftClient client = MinecraftClient.getInstance();
final Identifier blockId = Registry.BLOCK.getId(state.getBlock());
screen.setup((matrices, vertexConsumerProvider, tickDelta) -> {
matrices.push();
matrices.translate(-0.5, 0, -0.5);
client.getBlockRenderManager().renderBlockAsEntity(state, 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 (client.world.random.nextDouble() < 0.150) {
state.getBlock().randomDisplayTick(state, client.world, client.player.getBlockPos(), client.world.random);
}
});
}
use of net.minecraft.client.MinecraftClient in project isometric-renders by gliscowo.
the class IsometricRenderPresets method setupEntityRender.
public static void setupEntityRender(IsometricRenderScreen screen, @NotNull Entity entity) {
final MinecraftClient client = MinecraftClient.getInstance();
final Identifier entityId = Registry.ENTITY_TYPE.getId(entity.getType());
screen.setup((matrixStack, vertexConsumerProvider, delta) -> {
matrixStack.push();
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180));
entity.setPos(client.player.getX(), client.player.getY(), client.player.getZ());
client.getEntityRenderDispatcher().render(entity, 0, 0, 0, 0, delta, matrixStack, vertexConsumerProvider, 15728880);
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-180));
matrixStack.translate(0, 2, 0);
client.particleManager.renderParticles(matrixStack, (VertexConsumerProvider.Immediate) vertexConsumerProvider, client.gameRenderer.getLightmapTextureManager(), getParticleCamera(), delta);
matrixStack.pop();
}, entityId.getNamespace() + "/entities/" + entityId.getPath());
screen.setTickCallback(() -> {
client.world.tickEntity(entity);
});
screen.setClosedCallback(() -> {
entity.updatePosition(0, 0, 0);
});
}
use of net.minecraft.client.MinecraftClient in project EarthMCEssentials by EarthMC-Stats.
the class NearbyCommand method register.
public static void register() {
ClientCommandManager.DISPATCHER.register(ClientCommandManager.literal("nearby").executes(c -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null)
return -1;
Formatting headingFormatting = Formatting.byName(instance().getConfig().nearby.headingTextColour.name());
Formatting textFormatting = Formatting.byName(instance().getConfig().nearby.playerTextColour.name());
MsgUtils.sendPlayer("text_nearby_header", false, headingFormatting, false);
for (int i = 0; i < instance().getNearbyPlayers().size(); i++) {
JsonObject currentPlayer = instance().getNearbyPlayers().get(i).getAsJsonObject();
JsonElement xElement = currentPlayer.get("x");
JsonElement zElement = currentPlayer.get("z");
if (xElement == null || zElement == null)
continue;
int distance = Math.abs(xElement.getAsInt() - (int) client.player.getX()) + Math.abs(zElement.getAsInt() - (int) client.player.getZ());
String prefix = "";
if (instance().getConfig().nearby.showRank) {
if (!currentPlayer.has("town"))
prefix = new TranslatableText("text_nearby_rank_townless").toString();
else
prefix = "(" + currentPlayer.get("rank").getAsString() + ") ";
}
MsgUtils.sendPlayer(prefix + currentPlayer.get("name").getAsString() + ": " + distance + "m", false, textFormatting, false);
}
return 1;
}).then(ClientCommandManager.literal("refresh").executes(c -> {
instance().scheduler().stop();
instance().scheduler().start();
MsgUtils.sendPlayer("msg_nearby_refresh", false, Formatting.AQUA, true);
return 1;
})).then(ClientCommandManager.literal("clear").executes(c -> {
instance().setNearbyPlayers(new JsonArray());
MsgUtils.sendPlayer("msg_nearby_clear", false, Formatting.AQUA, true);
return 1;
})));
}
use of net.minecraft.client.MinecraftClient in project Terracraft by SimplyCmd.
the class MirrorItem method use.
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
if (// Get server player
playerEntity instanceof ServerPlayerEntity)
// Get server player
player = (ServerPlayerEntity) playerEntity;
else // Get client player
if (playerEntity instanceof ClientPlayerEntity)
clientPlayer = (ClientPlayerEntity) playerEntity;
if (!tick) {
final MinecraftClient client = MinecraftClient.getInstance();
client.particleManager.addEmitter(clientPlayer, ParticleTypes.END_ROD, 30);
client.gameRenderer.showFloatingItem(this.getDefaultStack());
player.getWorld().playSound(playerEntity, playerEntity.getBlockPos(), SoundRegistry.ITEM_MAGIC_MIRROR_USE_EVENT, SoundCategory.PLAYERS, 1f, 1f);
tick = true;
return TypedActionResult.success(playerEntity.getStackInHand(hand));
} else {
return TypedActionResult.fail(playerEntity.getStackInHand(hand));
}
}
use of net.minecraft.client.MinecraftClient in project Hypnotic-Client by Hypnotic-Development.
the class WorldUtils method getForwardBlock.
public static BlockPos getForwardBlock(double length) {
MinecraftClient mc = MinecraftClient.getInstance();
final double yaw = Math.toRadians(mc.player.getYaw());
BlockPos fPos = new BlockPos(mc.player.getX() + (-Math.sin(yaw) * length), mc.player.getY(), mc.player.getZ() + (Math.cos(yaw) * length));
return fPos;
}
Aggregations