Don't render anything if power level is zero
This commit is contained in:
parent
c3776c9207
commit
3522987de5
@ -1,13 +1,11 @@
|
|||||||
package ru.dbotthepony.mc.otm.client.render.blockentity
|
package ru.dbotthepony.mc.otm.client.render.blockentity
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack
|
import com.mojang.blaze3d.vertex.PoseStack
|
||||||
import com.mojang.math.Vector3f
|
import com.mojang.math.Vector3f
|
||||||
import net.minecraft.client.renderer.MultiBufferSource
|
import net.minecraft.client.renderer.MultiBufferSource
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import org.lwjgl.opengl.GL30.*
|
|
||||||
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
import ru.dbotthepony.mc.otm.block.RotatableMatteryBlock
|
||||||
import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.BatteryBankBlockEntity
|
||||||
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
|
||||||
@ -15,8 +13,6 @@ import ru.dbotthepony.mc.otm.block.entity.matter.MatterCapacitorBankBlockEntity
|
|||||||
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AbstractSkinElement
|
||||||
import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement
|
import ru.dbotthepony.mc.otm.client.render.AtlasSkinElement
|
||||||
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
import ru.dbotthepony.mc.otm.client.render.SkinElement
|
|
||||||
import ru.dbotthepony.mc.otm.client.render.is3DContext
|
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
|
||||||
import ru.dbotthepony.mc.otm.core.get
|
import ru.dbotthepony.mc.otm.core.get
|
||||||
@ -34,49 +30,53 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
|
|||||||
p_112311_: Int,
|
p_112311_: Int,
|
||||||
p_112312_: Int
|
p_112312_: Int
|
||||||
) {
|
) {
|
||||||
is3DContext = true
|
val plainLevel = gaugeLevel(blockEntity)
|
||||||
|
|
||||||
try {
|
if (plainLevel <= 0f) {
|
||||||
stack.pushPose()
|
return
|
||||||
|
|
||||||
val facing = blockEntity.blockState[RotatableMatteryBlock.FACING]
|
|
||||||
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
|
|
||||||
|
|
||||||
if (rotateFacing) {
|
|
||||||
stack.mulPose(Vector3f.YP.rotation(PI.toFloat() / 2f))
|
|
||||||
}
|
|
||||||
|
|
||||||
stack.scale(0.02f, 0.01f, 0.01f)
|
|
||||||
stack.translate(if (rotateFacing) -50.0 else 0.0, 0.0, -0.5)
|
|
||||||
|
|
||||||
// ~50x100 canvas
|
|
||||||
|
|
||||||
val width = 9f
|
|
||||||
val heightMax = 39.36f
|
|
||||||
|
|
||||||
val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasSkinElement.renderTypeWorld)
|
|
||||||
|
|
||||||
texture.uploadOntoPartialColor(stack,
|
|
||||||
buffer,
|
|
||||||
x = 25f - width / 2f,
|
|
||||||
y = 30f,
|
|
||||||
width = width,
|
|
||||||
height = heightMax * gaugeLevel(blockEntity))
|
|
||||||
|
|
||||||
stack.mulPose(Vector3f.YP.rotation(PI.toFloat()))
|
|
||||||
stack.translate(-50.0, 0.0, -101.0)
|
|
||||||
|
|
||||||
texture.uploadOntoPartialColor(stack,
|
|
||||||
buffer,
|
|
||||||
x = 25f - width / 2f,
|
|
||||||
y = 30f,
|
|
||||||
width = width,
|
|
||||||
height = heightMax * gaugeLevel(blockEntity))
|
|
||||||
|
|
||||||
stack.popPose()
|
|
||||||
} finally {
|
|
||||||
is3DContext = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stack.pushPose()
|
||||||
|
|
||||||
|
val facing = blockEntity.blockState[RotatableMatteryBlock.FACING]
|
||||||
|
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
|
||||||
|
|
||||||
|
if (rotateFacing) {
|
||||||
|
stack.mulPose(Vector3f.YP.rotation(PI.toFloat() / 2f))
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.scale(0.02f, 0.01f, 0.01f)
|
||||||
|
stack.translate(if (rotateFacing) -50.0 else 0.0, 0.0, -0.5)
|
||||||
|
|
||||||
|
// ~50x100 canvas
|
||||||
|
|
||||||
|
val width = 9f
|
||||||
|
val heightMax = 39.36f
|
||||||
|
|
||||||
|
val buffer = DynamicBufferSource.WORLD.getBuffer(AtlasSkinElement.renderTypeWorld)
|
||||||
|
|
||||||
|
texture.uploadOntoPartialColor(
|
||||||
|
stack,
|
||||||
|
buffer,
|
||||||
|
x = 25f - width / 2f,
|
||||||
|
y = 30f,
|
||||||
|
width = width,
|
||||||
|
height = heightMax * gaugeLevel(blockEntity)
|
||||||
|
)
|
||||||
|
|
||||||
|
stack.mulPose(Vector3f.YP.rotation(PI.toFloat()))
|
||||||
|
stack.translate(-50.0, 0.0, -101.0)
|
||||||
|
|
||||||
|
texture.uploadOntoPartialColor(
|
||||||
|
stack,
|
||||||
|
buffer,
|
||||||
|
x = 25f - width / 2f,
|
||||||
|
y = 30f,
|
||||||
|
width = width,
|
||||||
|
height = heightMax * gaugeLevel(blockEntity)
|
||||||
|
)
|
||||||
|
|
||||||
|
stack.popPose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user