From 0ac27ff2bb8dedf8d12acd1f075487dd63cae1fd Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 29 Jan 2020 14:32:32 +0100 Subject: [PATCH] fixed custom renderers (particles, boxes) --- .../naturesaura/events/ClientEvents.java | 18 ++++++++---------- .../naturesaura/particles/ParticleHandler.java | 18 +++++------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index b414efa4..77f1e24a 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -27,6 +27,7 @@ import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.screen.ChatScreen; +import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.resources.I18n; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -36,10 +37,7 @@ import net.minecraft.item.Items; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Tuple; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.*; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; @@ -212,12 +210,12 @@ public class ClientEvents { @SubscribeEvent public void onWorldRender(RenderWorldLastEvent event) { Minecraft mc = Minecraft.getInstance(); - GL11.glPushMatrix(); - float partial = event.getPartialTicks(); - GL11.glTranslated( - -mc.player.prevPosX - (mc.player.getPosX() - mc.player.prevPosX) * partial, - -mc.player.prevPosY - (mc.player.getPosY() - mc.player.prevPosY) * partial - (double) MathHelper.lerp(partial, this.previousHeight, this.height), - -mc.player.prevPosZ - (mc.player.getPosZ() - mc.player.prevPosZ) * partial); + RenderSystem.pushMatrix(); + RenderSystem.multMatrix(event.getMatrixStack().getLast().getPositionMatrix()); + + ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo(); + Vec3d view = info.getProjectedView(); + GL11.glTranslated(-view.getX(), -view.getY(), -view.getZ()); if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.instance.debugWorld.get()) { Map spots = new HashMap<>(); diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index b7f0ba05..f691723c 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -10,6 +10,7 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.settings.ParticleStatus; import net.minecraft.util.math.MathHelper; @@ -68,20 +69,11 @@ public final class ParticleHandler { } public static void renderParticles(MatrixStack stack, float partialTicks) { - // TODO Render particles - if(true) - return; - Minecraft mc = Minecraft.getInstance(); ClientPlayerEntity player = mc.player; if (player != null) { ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo(); - float f = MathHelper.cos(info.getYaw() * ((float) Math.PI / 180F)); - float f1 = MathHelper.sin(info.getYaw() * ((float) Math.PI / 180F)); - float f2 = -f1 * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F)); - float f3 = f * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F)); - float f4 = MathHelper.cos(info.getPitch() * ((float) Math.PI / 180F)); RenderSystem.pushMatrix(); RenderSystem.multMatrix(stack.getLast().getPositionMatrix()); @@ -90,7 +82,7 @@ public final class ParticleHandler { GlStateManager.enableBlend(); RenderSystem.alphaFunc(516, 0.003921569F); GlStateManager.disableCull(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE.param); + RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); GlStateManager.depthMask(false); @@ -98,13 +90,13 @@ public final class ParticleHandler { Tessellator tessy = Tessellator.getInstance(); BufferBuilder buffer = tessy.getBuffer(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for (Particle particle : PARTICLES) particle.renderParticle(buffer, info, partialTicks); tessy.draw(); GlStateManager.disableDepthTest(); - buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX); + buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for (Particle particle : PARTICLES_NO_DEPTH) particle.renderParticle(buffer, info, partialTicks); tessy.draw(); @@ -112,7 +104,7 @@ public final class ParticleHandler { GlStateManager.enableCull(); GlStateManager.depthMask(true); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA.param, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA.param); + RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); RenderSystem.alphaFunc(516, 0.1F);