Use global buffer source
This commit is contained in:
parent
e88c2ba9b0
commit
90da43ec49
@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack
|
|||||||
import net.minecraft.client.Camera
|
import net.minecraft.client.Camera
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayer
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
|
|
||||||
abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: MatteryPlayer) : AndroidSwitchableFeature(type, android) {
|
abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: MatteryPlayer) : AndroidSwitchableFeature(type, android) {
|
||||||
/**
|
/**
|
||||||
@ -22,5 +23,5 @@ abstract class AndroidActiveFeature(type: AndroidFeatureType<*>, android: Matter
|
|||||||
*
|
*
|
||||||
* pose stack has pose pushed already
|
* pose stack has pose pushed already
|
||||||
*/
|
*/
|
||||||
abstract fun renderPreview(poseStack: PoseStack, camera: Camera)
|
abstract fun renderPreview(poseStack: PoseStack, camera: Camera, bufferSource: DynamicBufferSource)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import net.minecraft.core.BlockPos
|
|||||||
import net.minecraft.core.Direction
|
import net.minecraft.core.Direction
|
||||||
import net.minecraft.core.Vec3i
|
import net.minecraft.core.Vec3i
|
||||||
import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket
|
import net.minecraft.network.protocol.game.ClientboundSoundEntityPacket
|
||||||
import net.minecraft.resources.ResourceLocation
|
|
||||||
import net.minecraft.server.level.ServerPlayer
|
import net.minecraft.server.level.ServerPlayer
|
||||||
import net.minecraft.sounds.SoundEvents
|
import net.minecraft.sounds.SoundEvents
|
||||||
import net.minecraft.sounds.SoundSource
|
import net.minecraft.sounds.SoundSource
|
||||||
@ -323,7 +322,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
override val previewRenderStage: RenderLevelStageEvent.Stage
|
override val previewRenderStage: RenderLevelStageEvent.Stage
|
||||||
get() = RenderLevelStageEvent.Stage.AFTER_PARTICLES
|
get() = RenderLevelStageEvent.Stage.AFTER_PARTICLES
|
||||||
|
|
||||||
override fun renderPreview(poseStack: PoseStack, camera: Camera) {
|
override fun renderPreview(poseStack: PoseStack, camera: Camera, bufferSource: DynamicBufferSource) {
|
||||||
if (!canUse()) return
|
if (!canUse()) return
|
||||||
val (pos, phasedBlocks) = trace()
|
val (pos, phasedBlocks) = trace()
|
||||||
|
|
||||||
@ -350,7 +349,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
if (phasedBlocks.isNotEmpty()) {
|
if (phasedBlocks.isNotEmpty()) {
|
||||||
poseStack.popPose()
|
poseStack.popPose()
|
||||||
val collisionContext = CollisionContext.of(ply)
|
val collisionContext = CollisionContext.of(ply)
|
||||||
val builder = source.getBuffer(linesIgnoreZRenderType)
|
val builder = bufferSource.getBuffer(linesIgnoreZRenderType)
|
||||||
|
|
||||||
for (blockPos in phasedBlocks) {
|
for (blockPos in phasedBlocks) {
|
||||||
val blockState = ply.level().getBlockState(blockPos)
|
val blockState = ply.level().getBlockState(blockPos)
|
||||||
@ -367,7 +366,7 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
source.endBatch(linesIgnoreZRenderType)
|
bufferSource.endBatch(linesIgnoreZRenderType)
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.enableDepthTest()
|
RenderSystem.enableDepthTest()
|
||||||
@ -387,10 +386,6 @@ class EnderTeleporterFeature(capability: MatteryPlayer) : AndroidActiveFeature(A
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val source by lazy {
|
|
||||||
DynamicBufferSource(maximalInitialBufferSize = 256)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val SHAPE_CHECK_NOT_FENCE = Block.box(6.0, 17.0, 6.0, 10.0, 31.0, 10.0)
|
private val SHAPE_CHECK_NOT_FENCE = Block.box(6.0, 17.0, 6.0, 10.0, 31.0, 10.0)
|
||||||
private val SHAPE_CHECK_SUPPORT_PLAYER = Block.box(6.0, 0.0, 6.0, 10.0, 16.0, 10.0)
|
private val SHAPE_CHECK_SUPPORT_PLAYER = Block.box(6.0, 0.0, 6.0, 10.0, 16.0, 10.0)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
|
|||||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||||
import ru.dbotthepony.mc.otm.client.render.is3DContext
|
import ru.dbotthepony.mc.otm.client.render.is3DContext
|
||||||
import ru.dbotthepony.kommons.math.RGBAColor
|
import ru.dbotthepony.kommons.math.RGBAColor
|
||||||
|
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
|
||||||
import ru.dbotthepony.mc.otm.network.ActivateAndroidFeaturePacket
|
import ru.dbotthepony.mc.otm.network.ActivateAndroidFeaturePacket
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ object AndroidAbilityKeyMapping : KeyMapping("key.otm.android_ability", KeyConfl
|
|||||||
try {
|
try {
|
||||||
is3DContext = true
|
is3DContext = true
|
||||||
event.poseStack.pushPose()
|
event.poseStack.pushPose()
|
||||||
feature.renderPreview(event.poseStack, event.camera)
|
feature.renderPreview(event.poseStack, event.camera, DynamicBufferSource.WORLD)
|
||||||
} finally {
|
} finally {
|
||||||
is3DContext = false
|
is3DContext = false
|
||||||
event.poseStack.popPose()
|
event.poseStack.popPose()
|
||||||
|
Loading…
Reference in New Issue
Block a user