Untitled
unknown
java
3 years ago
4.6 kB
6
Indexable
package com.radon.naruto_universe.client.entity; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; import com.radon.naruto_universe.NarutoUniverse; import com.radon.naruto_universe.entity.projectile.FireBulletProjectile; import com.radon.naruto_universe.shader.ShaderRegistry; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleEngine; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.entity.*; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.Fireball; import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.ForgeRenderTypes; import java.util.Optional; public class FireBulletRenderer extends EntityRenderer<FireBulletProjectile> { private static ResourceLocation TEXTURE = new ResourceLocation(NarutoUniverse.MOD_ID, "textures/entity/fire_bullet.png"); public static RenderType NORMAL_RENDER = RenderType.create("normal",DefaultVertexFormat.PARTICLE, VertexFormat.Mode.QUADS, 256, false, false, RenderType.CompositeState.builder() .setTextureState(new RenderStateShard.EmptyTextureStateShard(() -> { RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); RenderSystem.setShader(() -> ShaderRegistry.BASIC_SHADER); RenderSystem.setShaderTexture(0, TEXTURE); Minecraft.getInstance().textureManager.getTexture(TEXTURE).setBlurMipmap(true, false); }, () -> { RenderSystem.disableBlend(); RenderSystem.depthMask(true); })).setShaderState(new RenderStateShard.ShaderStateShard(() -> ShaderRegistry.BASIC_SHADER)).createCompositeState(false)); public FireBulletRenderer(EntityRendererProvider.Context context) { super(context); } @Override public void render(FireBulletProjectile entity, float entityYaw, float partialTicks, PoseStack pMatrixStack, MultiBufferSource buffer, int packedLight) { Camera camera = Minecraft.getInstance().getEntityRenderDispatcher().camera; Vec3 position = camera.getPosition(); float x = (float)(Mth.lerp(partialTicks, entity.xo, entity.getX()) - position.x()); float y = (float)(Mth.lerp(partialTicks, entity.yo, entity.getY()) - position.y()); float z = (float)(Mth.lerp(partialTicks, entity.zo, entity.getZ()) - position.z()); Quaternion quaternion = camera.rotation(); new Vector3f(-1.0F, -1.0F, 0.0F).transform(quaternion); Vector3f[] rotation = new Vector3f[] { new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F) }; float quadSize = 10.0F; for (int i = 0; i < 4; ++i) { rotation[i].transform(quaternion); rotation[i].mul(quadSize); rotation[i].add(x, y, z); } int lightColor = 15728640; VertexConsumer consumer = buffer.getBuffer(NORMAL_RENDER); float U0 = 0.0F; float U1 = 1.0F; float V0 = 0.0F; float V1 = 1.0F; consumer.vertex(rotation[0].x(), rotation[0].y(), rotation[0].z()).uv(U1, V1).color(1.0F, 0.5F, 0.0F, 1.0F).uv2(lightColor).endVertex(); consumer.vertex(rotation[1].x(), rotation[1].y(), rotation[1].z()).uv(U1, V0).color(1.0F, 0.5F, 0.0F, 1.0F).uv2(lightColor).endVertex(); consumer.vertex(rotation[2].x(), rotation[2].y(), rotation[2].z()).uv(U0, V0).color(1.0F, 0.5F, 0.0F, 1.0F).uv2(lightColor).endVertex(); consumer.vertex(rotation[3].x(), rotation[3].y(), rotation[3].z()).uv(U0, V1).color(1.0F, 0.5F, 0.0F, 1.0F).uv2(lightColor).endVertex(); } @Override public ResourceLocation getTextureLocation(FireBulletProjectile pEntity) { return null; } }
Editor is loading...