-
Автор темы
- #1
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
на вам снег
Пожалуйста, авторизуйтесь для просмотра ссылки.
Код:
package im.expensive.functions.impl.render;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import im.expensive.events.EventUpdate;
import im.expensive.events.WorldEvent;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.render.ColorUtils;
import net.minecraft.block.BlockState;
import net.minecraft.client.gui.screen.IngameMenuScreen;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldVertexBufferUploader;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.optifine.shaders.Shaders;
import java.util.concurrent.CopyOnWriteArrayList;
import static net.minecraft.client.renderer.WorldRenderer.frustum;
@FunctionRegister(name = "Snow", server = "", description = "", type = Category.Render)
public class Snow extends Function {
private final ModeSetting fallModeSetting = new ModeSetting("Режим", "Простой", "Простой", "Отскоки", "Взлет");
public static final ModeSetting setting = new ModeSetting("Вид", "Сердечки", "cross", "lightning","Сердечки", "Звезд","Звезды", "Снежинки", "Ромб","Орбизы", "Доллары", "Круг", "Комета", "Череп", "Амогус", "Цветочек", "корона", "хуйпоймиче");
public final SliderSetting size = new SliderSetting("Количество", 350f, 100f, 5000f, 50f);
public final SliderSetting fallSpeed = new SliderSetting("Скорость", 0.4f, 0.01f, 2.0f, 0.01f);
MatrixStack matrixStack = new MatrixStack();
private static final CopyOnWriteArrayList<ParticleBase> particles = new CopyOnWriteArrayList<>();
private float dynamicSpeed = 0.1f;
public Snow() {
addSettings(fallModeSetting, setting, size, fallSpeed);
}
float alpha = Shaders.shaderPackLoaded ? 1f : 0.5f;
private boolean isInView(Vector3d pos) {
frustum.setCameraPosition(mc.getRenderManager().info.getProjectedView().x,
mc.getRenderManager().info.getProjectedView().y,
mc.getRenderManager().info.getProjectedView().z);
return frustum.isBoundingBoxInFrustum(new AxisAlignedBB(pos.add(-0.2, -0.2, -0.2), pos.add(0.2, 0.2, 0.2)));
}
@Subscribe
public void onUpdate(EventUpdate e) {
dynamicSpeed = (fallModeSetting.is("Отскоки")) ? 0.1f : fallSpeed.get();
particles.removeIf(ParticleBase::tick);
int particlesToCreate = (int) (size.get() - particles.size());
if (particlesToCreate > 0) {
for (int n = 0; n < particlesToCreate; ++n) {
if (mc.currentScreen instanceof IngameMenuScreen) return;
float spawnX = (float) (mc.player.getPosX() + MathUtil.random(-48.0F, 48.0F));
float spawnY = (float) (mc.player.getPosY() + MathUtil.random(-20.0F, fallModeSetting.is("Взлет") ? 0 : 48.0F));
float spawnZ = (float) (mc.player.getPosZ() + MathUtil.random(-48.0F, 48.0F));
float motionX = MathUtil.random(-dynamicSpeed, dynamicSpeed);
float motionY = MathUtil.random(-0.1F, 0.1F);
float motionZ = MathUtil.random(-dynamicSpeed, dynamicSpeed);
int startAge = (int) MathUtil.random(0, 100);
particles.add(new ParticleBase(spawnX, spawnY, spawnZ, motionX, motionY, motionZ, startAge));
}
}
particles.removeIf(particleBase -> System.currentTimeMillis() - particleBase.time > 5000);
}
@Subscribe
private void onRender(WorldEvent e) {
render(matrixStack);
}
public static void render(MatrixStack matrixStack) {
if (mc.currentScreen instanceof IngameMenuScreen) return;
matrixStack.push();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
RenderSystem.enableDepthTest();
RenderSystem.depthMask(false);
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP);
particles.forEach(particleBase -> particleBase.render(bufferBuilder));
bufferBuilder.finishDrawing();
WorldVertexBufferUploader.draw(bufferBuilder);
RenderSystem.depthMask(true);
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.disableDepthTest();
RenderSystem.disableBlend();
matrixStack.pop();
}
public class ParticleBase {
public long time;
protected float prevposX, prevposY, prevposZ;
protected float posX, posY, posZ;
protected float motionX, motionY, motionZ;
protected int age, maxAge;
private float alpha;
private long collisionTime = -1L;
public ParticleBase(float x, float y, float z, float motionX, float motionY, float motionZ, int startAge) {
this.posX = x;
this.posY = y;
this.posZ = z;
this.prevposX = x;
this.prevposY = y;
this.prevposZ = z;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.time = System.currentTimeMillis();
this.maxAge = this.age = (int) MathUtil.random(120, 200);
this.age = this.maxAge - startAge; //применяем рандомный возраст
}
public void update() {
alpha = MathUtil.fast(alpha, 1, 10);
if (fallModeSetting.is("Отскоки")) updateWithBounce();
}
public boolean tick() {
this.age = mc.player.getDistanceSq((double) this.posX, (double) this.posY, (double) this.posZ) > 4096.0 ? (this.age -= 8) : --this.age;
if (this.age < 0) {
return true;
} else {
this.prevposX = this.posX;
this.prevposY = this.posY;
this.prevposZ = this.posZ;
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
if (fallModeSetting.is("Простой")) {
this.motionX *= 0.9F;
this.motionY *= 0.9F;
this.motionZ *= 0.9F;
this.motionY -= 0.001F * fallSpeed.get();
} else {
if (fallModeSetting.is("Взлет")) motionY += 0.1f * fallSpeed.get();
this.motionX = 0;
this.motionZ = 0;
}
return false;
}
}
private void updateWithBounce() {
if (this.collisionTime != -1L) {
long timeSinceCollision = System.currentTimeMillis() - this.collisionTime;
this.alpha = Math.max(0.0f, 1.0f - (float) timeSinceCollision / 3000.0f);
}
this.motionY -= 8.0E-4 * fallSpeed.get();
float newPosX = this.posX + this.motionX;
float newPosY = this.posY + this.motionY;
float newPosZ = this.posZ + this.motionZ;
BlockPos particlePos = new BlockPos(newPosX, newPosY, newPosZ);
BlockState blockState = mc.world.getBlockState(particlePos);
if (!blockState.isAir()) {
if (this.collisionTime == -1L) {
this.collisionTime = System.currentTimeMillis();
}
if (!mc.world.getBlockState(new BlockPos(this.posX + this.motionX, this.posY, this.posZ)).isAir()) {
this.motionX = 0.0f;
}
if (!mc.world.getBlockState(new BlockPos(this.posX, this.posY + this.motionY, this.posZ)).isAir()) {
this.motionY = -this.motionY * 0.8f;
}
if (!mc.world.getBlockState(new BlockPos(this.posX, this.posY, this.posZ + this.motionZ)).isAir()) {
this.motionZ = 0.0f;
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
} else {
this.posX = newPosX;
this.posY = newPosY;
this.posZ = newPosZ;
}
}
public void render(BufferBuilder bufferBuilder) {
float size = 1 - ((System.currentTimeMillis() - time) / 5000f);
ResourceLocation texture = null;
if (setting.is("Сердечки")) {
texture = new ResourceLocation("expensive/images/heart.png");
} else if (setting.is("Снежинки")) {
texture = new ResourceLocation("expensive/images/f.png");
} else if (setting.is("Звезды")) {
texture = new ResourceLocation("expensive/images/stars.png");
} else if (setting.is("Орбизы")) {
texture = new ResourceLocation("expensive/images/bloom.png");
} else if (setting.is("Круг")) {
texture = new ResourceLocation("expensive/images/circle.png");
} else if (setting.is("Доллары")) {
texture = new ResourceLocation("expensive/images/dollar.png");
} else if (setting.is("gray")) {
texture = new ResourceLocation("expensive/images/glow.png");
} else if (setting.is("Комета")) {
texture = new ResourceLocation("expensive/images/cometa.png");
} else if (setting.is("корона")) {
texture = new ResourceLocation("expensive/images/crown.png");
} else if (setting.is("Амогус")) {
texture = new ResourceLocation("expensive/images/amongus.png");
} else if (setting.is("Цветочек")) {
texture = new ResourceLocation("expensive/images/flower.png");
} else if (setting.is("хуйпоймиче")) {
texture = new ResourceLocation("expensive/images/polygon.png");
} else if (setting.is("Череп")) {
texture = new ResourceLocation("expensive/images/skull.png");
} else if (setting.is("cross")) {
texture = new ResourceLocation("expensive/images/cross.png");
} else if (setting.is("Ромб")) {
texture = new ResourceLocation("expensive/images/rhombus.png");
} else if (setting.is("Звезд")) {
texture = new ResourceLocation("expensive/images/star.png");
} else if (setting.is("lightning")) {
texture = new ResourceLocation("expensive/images/lightning.png");
}
if(texture == null) return;
mc.getTextureManager().bindTexture(texture);
update();
ActiveRenderInfo camera = mc.gameRenderer.getActiveRenderInfo();
int color = ColorUtils.setAlpha(ColorUtils.rgb(255, 255, 255), (int) ((255 * alpha) * size));
Vector3d pos = MathUtil.interpolatePos(prevposX, prevposY, prevposZ, posX, posY, posZ);
MatrixStack matrices = new MatrixStack();
matrices.translate(pos.x, pos.y, pos.z);
matrices.rotate(Vector3f.YP.rotationDegrees(-camera.getYaw()));
matrices.rotate(Vector3f.XP.rotationDegrees(camera.getPitch()));
Matrix4f matrix1 = matrices.getLast().getMatrix();
bufferBuilder.pos(matrix1, 0, -0.9f * size, 0).color(color).tex(0, 1).lightmap(0, 240).endVertex();
bufferBuilder.pos(matrix1, -0.9f * size, -0.9f * size, 0).color(color).tex(1, 1).lightmap(0, 240).endVertex();
bufferBuilder.pos(matrix1, -0.9f * size, 0, 0).color(color).tex(1, 0).lightmap(0, 240).endVertex();
bufferBuilder.pos(matrix1, 0, 0, 0).color(color).tex(0, 0).lightmap(0, 240).endVertex();
}
}
}