Начинающий
- Статус
- Оффлайн
- Регистрация
- 9 Мар 2025
- Сообщения
- 178
- Реакции
- 12
- Выберите загрузчик игры
- Fabric
прикольная вещица может кто то возмет хз
SS:
SS:
Пожалуйста, авторизуйтесь для просмотра ссылки.
heavens:
package ru.troll.module.impl.visuals;
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.pipeline.RenderPipeline.Snippet;
import com.mojang.blaze3d.platform.DepthTestFunction;
import com.mojang.blaze3d.vertex.VertexFormat.DrawMode;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderSetup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.util.Identifier;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.client.render.VertexConsumerProvider.Immediate;
import org.joml.Matrix4f;
import ru.troll.event.EventInit;
import ru.troll.event.player.EventMotion;
import ru.troll.event.render.EventRender3D;
import ru.troll.module.api.Category;
import ru.troll.module.api.IModule;
import ru.troll.module.api.Module;
import ru.troll.module.api.setting.Setting;
import ru.troll.module.api.setting.impl.SliderSetting;
import ru.troll.util.color.ColorUtil;
import ru.troll.util.render.math.animation.Animation;
import ru.troll.util.render.math.animation.Direction;
import ru.troll.util.render.math.animation.impl.EaseInOutQuad;
import ru.troll.util.render.world.WorldRenderUtil;
@IModule(name = "Heavens", description = "Плоские кубики на земле со столбиками", category = Category.Visuals, bind = -1)
@Environment(EnvType.CLIENT)
public class Heavens extends Module {
private final List<Heavens.Tile> tiles = new ArrayList<>();
private static final Identifier GLOW_TEXTURE_C = Identifier.of("noxium", "textures/world/dashbloom.png");
private static final Identifier GLOW_TEXTURE_G = Identifier.of("noxium", "textures/world/dashbloomsample.png");
public static SliderSetting tileCount = new SliderSetting("Количество плиток", 20.0F, 5.0F, 100.0F, 1.0F, false);
public static SliderSetting spawnRadius = new SliderSetting("Радиус появления", 3.0F, 1.0F, 10.0F, 0.5F, false);
public static SliderSetting tileSize = new SliderSetting("Размер плитки", 0.3F, 0.1F, 0.8F, 0.05F, false);
public static SliderSetting tileThickness = new SliderSetting("Толщина плитки", 0.05F, 0.01F, 0.15F, 0.01F, false);
public static SliderSetting pillarHeight = new SliderSetting("Высота столбика", 0.5F, 0.1F, 2.0F, 0.05F, false);
public static SliderSetting pillarWidth = new SliderSetting("Ширина столбика", 0.08F, 0.02F, 0.3F, 0.01F, false);
public static SliderSetting animationSpeed = new SliderSetting("Скорость анимации", 800.0F, 200.0F, 2000.0F, 50.0F, false);
public static SliderSetting lifetime = new SliderSetting("Время жизни (сек)", 5.0F, 1.0F, 15.0F, 0.5F, false);
public static SliderSetting glowIntensity = new SliderSetting("Интенсивность свечения", 1.0F, 0.1F, 3.0F, 0.1F, false);
public static SliderSetting tileAlpha = new SliderSetting("Прозрачность плитки", 0.3F, 0.1F, 1.0F, 0.05F, false);
public static SliderSetting pillarAlpha = new SliderSetting("Прозрачность столбика", 0.6F, 0.1F, 1.0F, 0.05F, false);
// Render pipelines
private static final RenderPipeline COLOR_PIPELINE = RenderPipelines.register(
RenderPipeline.builder(new Snippet[] { RenderPipelines.POSITION_COLOR_SNIPPET })
.withLocation(Identifier.of("noxium", "heavens_color"))
.withVertexFormat(VertexFormats.POSITION_COLOR, DrawMode.QUADS)
.withCull(false)
.withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
.withDepthWrite(false)
.withBlend(BlendFunction.LIGHTNING)
.build());
private static final RenderLayer COLOR_QUADS_LAYER = RenderLayer.of("heavens_tiles",
RenderSetup.builder(COLOR_PIPELINE).expectedBufferSize(2048).translucent().build());
private static final RenderPipeline GLOW_PIPELINE = RenderPipelines.register(
RenderPipeline.builder(new Snippet[] { RenderPipelines.POSITION_TEX_COLOR_SNIPPET })
.withLocation(Identifier.of("noxium", "heavens_glow"))
.withVertexFormat(VertexFormats.POSITION_TEXTURE_COLOR, DrawMode.QUADS)
.withCull(false)
.withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
.withDepthWrite(false)
.withBlend(BlendFunction.LIGHTNING)
.build());
private static final RenderLayer GLOW_LAYER = RenderLayer.of("heavens_glow",
RenderSetup.builder(GLOW_PIPELINE).expectedBufferSize(2048).translucent()
.texture("Sampler0", GLOW_TEXTURE_C).build());
private static final RenderLayer GLOW_LAYER_G = RenderLayer.of("heavens_glow_g",
RenderSetup.builder(GLOW_PIPELINE).expectedBufferSize(2048).translucent()
.texture("Sampler0", GLOW_TEXTURE_G).build());
public Heavens() {
this.addSettings(new Setting[] {
tileCount, spawnRadius,
tileSize, tileThickness,
pillarHeight, pillarWidth,
animationSpeed, lifetime,
glowIntensity, tileAlpha, pillarAlpha
});
}
@Override
public void onEnable() {
super.onEnable();
tiles.clear();
if (mc.player != null) {
mc.player.sendMessage(net.minecraft.text.Text.literal("§a[Heavens] Модуль включен!"), false);
}
}
@Override
public void onDisable() {
super.onDisable();
tiles.clear();
if (mc.player != null) {
mc.player.sendMessage(net.minecraft.text.Text.literal("§c[Heavens] Модуль выключен!"), false);
}
}
@EventInit
public void onUpdate(EventMotion e) {
if (mc.player == null || mc.world == null) return;
double playerX = mc.player.getX();
double playerY = mc.player.getY();
double playerZ = mc.player.getZ();
tiles.removeIf(tile -> {
double distance = Math.sqrt(
Math.pow(tile.x - playerX, 2) +
Math.pow(tile.z - playerZ, 2)
);
return distance > spawnRadius.get() + 5.0;
});
if (tiles.size() < tileCount.get()) {
double radius = spawnRadius.get();
double angle = Math.random() * Math.PI * 2.0;
double distance = Math.random() * radius;
double x = playerX + Math.cos(angle) * distance;
double z = playerZ + Math.sin(angle) * distance;
BlockPos groundPos = findGround(x, playerY, z);
double finalY = groundPos != null ? groundPos.getY() : playerY - 1.0;
tiles.add(new Heavens.Tile(x, finalY, z));
}
}
private BlockPos findGround(double x, double startY, double z) {
BlockPos startPos = BlockPos.ofFloored(x, startY, z);
for (int i = 0; i < 10; i++) {
BlockPos checkPos = startPos.down(i);
if (mc.world.getBlockState(checkPos).isSolidBlock(mc.world, checkPos)) {
return checkPos.up(1);
}
}
for (int i = 1; i < 5; i++) {
BlockPos checkPos = startPos.up(i);
if (mc.world.getBlockState(checkPos).isSolidBlock(mc.world, checkPos)) {
return checkPos.up(1);
}
}
return startPos;
}
@EventInit
public void onRender3D(EventRender3D e) {
if (tiles.isEmpty()) {
return;
}
Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
MatrixStack matrices = e.getMatrixStack();
Vec3d cameraPos = mc.gameRenderer.getCamera().getCameraPos();
long now = System.currentTimeMillis();
float cameraYaw = mc.gameRenderer.getCamera().getYaw();
float cameraPitch = mc.gameRenderer.getCamera().getPitch();
int baseColor = ColorUtil.fade();
int rendered = 0;
for (Heavens.Tile tile : tiles) {
tile.update(now);
tile.render(matrices, immediate, cameraPos, baseColor, cameraYaw, cameraPitch);
rendered++;
}
immediate.draw();
}
private static void drawFlatTile(VertexConsumer b, Matrix4f m, int color) {
float size = tileSize.get();
float thickness = tileThickness.get();
float half = size / 2.0F;
float th = thickness / 2.0F;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int bl = color & 0xFF;
int a = (color >> 24) & 0xFF;
b.vertex(m, -half, th, -half).color(r, g, bl, a);
b.vertex(m, -half, th, half).color(r, g, bl, a);
b.vertex(m, half, th, half).color(r, g, bl, a);
b.vertex(m, half, th, -half).color(r, g, bl, a);
b.vertex(m, -half, -th, -half).color(r, g, bl, a);
b.vertex(m, half, -th, -half).color(r, g, bl, a);
b.vertex(m, half, -th, half).color(r, g, bl, a);
b.vertex(m, -half, -th, half).color(r, g, bl, a);
b.vertex(m, -half, -th, -half).color(r, g, bl, a);
b.vertex(m, -half, -th, half).color(r, g, bl, a);
b.vertex(m, -half, th, half).color(r, g, bl, a);
b.vertex(m, -half, th, -half).color(r, g, bl, a);
b.vertex(m, half, -th, -half).color(r, g, bl, a);
b.vertex(m, half, th, -half).color(r, g, bl, a);
b.vertex(m, half, th, half).color(r, g, bl, a);
b.vertex(m, half, -th, half).color(r, g, bl, a);
b.vertex(m, -half, -th, -half).color(r, g, bl, a);
b.vertex(m, -half, th, -half).color(r, g, bl, a);
b.vertex(m, half, th, -half).color(r, g, bl, a);
b.vertex(m, half, -th, -half).color(r, g, bl, a);
b.vertex(m, -half, -th, half).color(r, g, bl, a);
b.vertex(m, half, -th, half).color(r, g, bl, a);
b.vertex(m, half, th, half).color(r, g, bl, a);
b.vertex(m, -half, th, half).color(r, g, bl, a);
}
private static void drawPillar(VertexConsumer b, Matrix4f m, int color, float height) {
float width = pillarWidth.get();
float hw = width / 2.0F;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int bl = color & 0xFF;
int a = (color >> 24) & 0xFF;
b.vertex(m, -hw, height, -hw).color(r, g, bl, a);
b.vertex(m, -hw, height, hw).color(r, g, bl, a);
b.vertex(m, hw, height, hw).color(r, g, bl, a);
b.vertex(m, hw, height, -hw).color(r, g, bl, a);
b.vertex(m, -hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, hw, 0, hw).color(r, g, bl, a);
b.vertex(m, -hw, 0, hw).color(r, g, bl, a);
// Боковые грани
b.vertex(m, -hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, -hw, 0, hw).color(r, g, bl, a);
b.vertex(m, -hw, height, hw).color(r, g, bl, a);
b.vertex(m, -hw, height, -hw).color(r, g, bl, a);
b.vertex(m, hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, hw, height, -hw).color(r, g, bl, a);
b.vertex(m, hw, height, hw).color(r, g, bl, a);
b.vertex(m, hw, 0, hw).color(r, g, bl, a);
b.vertex(m, -hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, -hw, height, -hw).color(r, g, bl, a);
b.vertex(m, hw, height, -hw).color(r, g, bl, a);
b.vertex(m, hw, 0, -hw).color(r, g, bl, a);
b.vertex(m, -hw, 0, hw).color(r, g, bl, a);
b.vertex(m, hw, 0, hw).color(r, g, bl, a);
b.vertex(m, hw, height, hw).color(r, g, bl, a);
b.vertex(m, -hw, height, hw).color(r, g, bl, a);
}
@Environment(EnvType.CLIENT)
public static class Tile {
double x, y, z;
long startTime;
Animation animation = new EaseInOutQuad(800, 1.0);
float cachedAlpha = 0.0F;
long lastAlphaUpdate = 0L;
private static final MinecraftClient mc = MinecraftClient.getInstance();
public Tile(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
this.startTime = System.currentTimeMillis();
// Создаем анимацию с текущей скоростью
int speed = (int) animationSpeed.get();
this.animation = new EaseInOutQuad(speed, 1.0);
this.animation.setDirection(Direction.FORWARDS);
}
public void update(long now) {
// Плитки не исчезают по времени, только когда игрок отходит
if (now - lastAlphaUpdate > 16L) {
cachedAlpha = animation.getOutput();
lastAlphaUpdate = now;
}
}
public boolean shouldRemove() {
// Удаляем только если анимация закончилась
return animation.getDirection() == Direction.BACKWARDS && cachedAlpha <= 0.0F;
}
public void render(MatrixStack matrices, VertexConsumerProvider immediate, Vec3d cameraPos,
int baseColor, float cameraYaw, float cameraPitch) {
float alpha = cachedAlpha;
if (alpha <= 0.0F) return;
float relX = (float) (x - cameraPos.x);
float relY = (float) (y - cameraPos.y);
float relZ = (float) (z - cameraPos.z);
int tileColor = ColorUtil.multAlpha(baseColor, alpha * tileAlpha.get());
int pillarColor = ColorUtil.multAlpha(baseColor, alpha * pillarAlpha.get());
int glowColor = ColorUtil.multAlpha(baseColor, alpha);
// Рендерим плоскую плитку
matrices.push();
matrices.translate(relX, relY, relZ);
Matrix4f mat = matrices.peek().getPositionMatrix();
drawFlatTile(immediate.getBuffer(COLOR_QUADS_LAYER), mat, tileColor);
matrices.pop();
// Рендерим столбик в центре с анимацией высоты
float currentHeight = pillarHeight.get() * alpha;
float thickness = tileThickness.get();
matrices.push();
matrices.translate(relX, relY + thickness, relZ);
Matrix4f pillarMat = matrices.peek().getPositionMatrix();
drawPillar(immediate.getBuffer(COLOR_QUADS_LAYER), pillarMat, pillarColor, currentHeight);
matrices.pop();
// Рендерим glow эффект на столбике
matrices.push();
matrices.translate(relX, relY + thickness + currentHeight / 2.0F, relZ);
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-cameraYaw));
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(cameraPitch));
Matrix4f glowMat = matrices.peek().getPositionMatrix();
float intensity = glowIntensity.get();
float pWidth = pillarWidth.get();
float glowSize = pWidth * 8.0F * intensity;
float glowSize2 = pWidth * 3.0F * intensity;
WorldRenderUtil.drawGlow(immediate.getBuffer(GLOW_LAYER), glowMat, glowColor,
(int) (100.0F * alpha * intensity), glowSize);
WorldRenderUtil.drawGlow(immediate.getBuffer(GLOW_LAYER_G), glowMat, glowColor,
(int) (180.0F * alpha * intensity), glowSize2);
matrices.pop();
}
}
}

/del