plasma projectile render
This commit is contained in:
parent
7f22b1e175
commit
54bc1bdd40
@ -1,36 +1,50 @@
|
||||
package ru.dbotthepony.mc.otm.client.render.entity
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import com.mojang.math.Axis
|
||||
import net.minecraft.client.renderer.MultiBufferSource
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.render.drawAligned
|
||||
import ru.dbotthepony.mc.otm.client.render.rotateAroundPoint
|
||||
import ru.dbotthepony.mc.otm.client.render.translation
|
||||
import ru.dbotthepony.mc.otm.core.math.Angle
|
||||
import ru.dbotthepony.mc.otm.OverdriveThatMatters.loc
|
||||
import ru.dbotthepony.mc.otm.entity.PlasmaProjectile
|
||||
|
||||
class PlasmaProjectileRenderer(context: EntityRendererProvider.Context) : EntityRenderer<PlasmaProjectile>(context) {
|
||||
override fun getTextureLocation(p_114482_: PlasmaProjectile): ResourceLocation {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
override fun getTextureLocation(p_114482_: PlasmaProjectile): ResourceLocation = PLASMA_PROJECTILE_LOCATION
|
||||
|
||||
override fun render(
|
||||
entity: PlasmaProjectile,
|
||||
p_114486_: Float,
|
||||
p_114487_: Float,
|
||||
pose: PoseStack,
|
||||
entityYaw: Float,
|
||||
partialTick: Float,
|
||||
poseStack: PoseStack,
|
||||
buffer: MultiBufferSource,
|
||||
p_114490_: Int
|
||||
packedLight: Int
|
||||
) {
|
||||
super.render(entity, p_114486_, p_114487_, pose, buffer, p_114490_)
|
||||
val consumer = buffer.getBuffer(RENDER_TYPE)
|
||||
|
||||
pose.pushPose()
|
||||
pose.scale(0.03f, 0.03f, 0.03f)
|
||||
pose.rotateAroundPoint(pose.translation(), Angle.deg(roll = entity.xRot.toDouble(), yaw = entity.yRot.toDouble(), pitch = 180.0))
|
||||
font.drawAligned(pose, "PLASMA", RenderGravity.CENTER_CENTER, 0f, 0f, 0xFFFFFF)
|
||||
pose.popPose()
|
||||
poseStack.pushPose()
|
||||
|
||||
poseStack.mulPose(entityRenderDispatcher.cameraOrientation())
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(180f))
|
||||
poseStack.scale(.3f, .3f, .3f)
|
||||
|
||||
val matrix = poseStack.last().pose()
|
||||
val normal = poseStack.last().normal()
|
||||
|
||||
consumer.vertex(matrix, -.5f, -.5f, 0f).color(1f, 1f, 1f, 1f).uv(0f, 1f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex()
|
||||
consumer.vertex(matrix, .5f, -.5f, 0f).color(1f, 1f, 1f, 1f).uv(1f, 1f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex()
|
||||
consumer.vertex(matrix, .5f, .5f, 0f).color(1f, 1f, 1f, 1f).uv(1f, 0f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex()
|
||||
consumer.vertex(matrix, -.5f, .5f, 0f).color(1f, 1f, 1f, 1f).uv(0f, 0f).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(packedLight).normal(normal, 0f, 1f, 0f).endVertex()
|
||||
|
||||
poseStack.popPose()
|
||||
|
||||
super.render(entity, entityYaw, partialTick, poseStack, buffer, packedLight)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val PLASMA_PROJECTILE_LOCATION: ResourceLocation = loc("textures/misc/plasma_ball.png")
|
||||
private val RENDER_TYPE = RenderType.itemEntityTranslucentCull(PLASMA_PROJECTILE_LOCATION)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user