started working top to bottom fixing things.

This commit is contained in:
Talia-12 2023-06-15 23:11:45 +10:00
parent 80386c4262
commit 1342c8cbef
5 changed files with 16 additions and 11 deletions

View file

@ -8,7 +8,6 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidIota
import at.petrak.hexcasting.api.casting.mishaps.MishapNotEnoughArgs
import at.petrak.hexcasting.api.utils.asTranslatedComponent
import com.mojang.datafixers.util.Either
import com.mojang.math.Vector3f
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.Entity
@ -17,6 +16,7 @@ import net.minecraft.world.entity.Mob
import net.minecraft.world.entity.decoration.ArmorStand
import net.minecraft.world.entity.item.ItemEntity
import net.minecraft.world.phys.Vec3
import org.joml.Vector3f
import java.util.function.DoubleUnaryOperator
import kotlin.math.abs
import kotlin.math.roundToInt
@ -238,7 +238,7 @@ fun List<Iota>.getIntBetween(idx: Int, min: Int, max: Int, argc: Int = 0): Int {
fun List<Iota>.getBlockPos(idx: Int, argc: Int = 0): BlockPos {
val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) }
if (x is Vec3Iota) {
return BlockPos(x.vec3)
return BlockPos.containing(x.vec3)
}
throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "vector")

View file

@ -80,7 +80,7 @@ abstract class Mishap : Throwable() {
companion object {
@JvmStatic
fun trulyHurt(entity: LivingEntity, source: DamageSource, amount: Float) {
entity.setHurtWithStamp(source, entity.level.gameTime)
entity.setHurtWithStamp(source, entity.level().gameTime)
val targetHealth = entity.health - amount
if (entity.invulnerableTime > 10) {
@ -92,7 +92,7 @@ abstract class Mishap : Throwable() {
}
if (!entity.hurt(source, amount) &&
!entity.isInvulnerableTo(source) &&
!entity.level.isClientSide &&
!entity.level().isClientSide &&
!entity.isDeadOrDying
) {

View file

@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.world.item.DyeColor
import net.minecraft.world.level.Explosion
import net.minecraft.world.level.Level
import net.minecraft.world.phys.Vec3
class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
@ -16,7 +17,7 @@ class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
dyeColor(DyeColor.LIME)
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Explosion.BlockInteraction.NONE)
ctx.world.explode(null, pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, 0.25f, Level.ExplosionInteraction.NONE)
}
override fun particleSpray(ctx: CastingEnvironment) =

View file

@ -23,6 +23,7 @@ import at.petrak.hexcasting.xplat.IClientXplatAbstractions
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.resources.sounds.SimpleSoundInstance
@ -300,12 +301,14 @@ class GuiSpellcasting constructor(
}
override fun render(ps: PoseStack, pMouseX: Int, pMouseY: Int, pPartialTick: Float) {
super.render(ps, pMouseX, pMouseY, pPartialTick)
override fun render(graphics: GuiGraphics, pMouseX: Int, pMouseY: Int, pPartialTick: Float) {
super.render(graphics, pMouseX, pMouseY, pPartialTick)
this.ambianceSoundInstance?.mousePosX = pMouseX / this.width.toDouble()
this.ambianceSoundInstance?.mousePosY = pMouseX / this.width.toDouble()
val ps = graphics.pose() // TODO: Determine if this is still necessary.
val mat = ps.last().pose()
val prevShader = RenderSystem.getShader()
RenderSystem.setShader(GameRenderer::getPositionColorShader)
@ -425,7 +428,7 @@ class GuiSpellcasting constructor(
ps.translate(0.0, 0.0, 1.0)
RenderSystem.setShader { prevShader }
for (desc in this.stackDescs) {
font.draw(ps, desc, 5f, 7f, -1)
graphics.drawString(font, desc, 5, 7, -1) // TODO: Confirm this works
ps.translate(0.0, 10.0, 0.0)
}
}
@ -451,7 +454,7 @@ class GuiSpellcasting constructor(
val color = 0x00_ffffff or (opacity shl 24)
RenderSystem.setShader { prevShader }
font.draw(ps, kotlinBad, 0f, 0f, color)
graphics.drawString(font, kotlinBad, 0, 0, color) // TODO: Confirm this works
ps.popPose()
}

View file

@ -11,8 +11,6 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.blaze3d.vertex.Tesselator
import com.mojang.blaze3d.vertex.VertexFormat
import com.mojang.math.Matrix4f
import com.mojang.math.Vector3f
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.MultiBufferSource
@ -25,6 +23,8 @@ import net.minecraft.world.level.Level
import net.minecraft.world.level.levelgen.SingleThreadedRandomSource
import net.minecraft.world.level.levelgen.synth.SimplexNoise
import net.minecraft.world.phys.Vec2
import org.joml.Matrix4f
import org.joml.Vector3f
import kotlin.math.abs
import kotlin.math.min
import kotlin.math.roundToInt
@ -424,6 +424,7 @@ fun renderEntity(
) {
val rotation = if (Screen.hasShiftDown()) 0.0f else rotation
// TODO: Figure out why this is here and whether removing it will break things
entity.level = world
ms.pushPose()
ms.translate(x.toDouble(), y.toDouble(), 50.0)