More backporting

This commit is contained in:
DBotThePony 2024-01-02 00:24:18 +07:00
parent 3fc9435259
commit 09f4db3fa9
Signed by: DBot
GPG Key ID: DCC23B5715498507
25 changed files with 256 additions and 162 deletions

View File

@ -18,7 +18,7 @@ private fun nothingOrNumber(input: Int): String {
return (input - 1).toString() return (input - 1).toString()
} }
open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(event.generator.packOutput, DataGen.MOD_ID, event.existingFileHelper) { open class BatteryBankProvider(event: GatherDataEvent) : BlockStateProvider(event.generator, DataGen.MOD_ID, event.existingFileHelper) {
protected var block = "battery_bank" protected var block = "battery_bank"
protected var batteryPath = "block/battery/battery" protected var batteryPath = "block/battery/battery"
protected var registry: Block = MBlocks.BATTERY_BANK protected var registry: Block = MBlocks.BATTERY_BANK

View File

@ -3,31 +3,29 @@ package ru.dbotthepony.mc.otm.android
import com.google.gson.JsonObject import com.google.gson.JsonObject
import it.unimi.dsi.fastutil.objects.ObjectArraySet import it.unimi.dsi.fastutil.objects.ObjectArraySet
import net.minecraft.data.CachedOutput import net.minecraft.data.CachedOutput
import net.minecraft.data.DataGenerator
import net.minecraft.data.DataProvider import net.minecraft.data.DataProvider
import net.minecraft.data.PackOutput
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraftforge.data.event.GatherDataEvent import net.minecraftforge.data.event.GatherDataEvent
import ru.dbotthepony.mc.otm.core.toJson
import ru.dbotthepony.mc.otm.core.toJsonStrict import ru.dbotthepony.mc.otm.core.toJsonStrict
import ru.dbotthepony.mc.otm.core.util.WriteOnce import ru.dbotthepony.mc.otm.core.util.WriteOnce
import java.util.Collections import java.util.Collections
import java.util.LinkedList import java.util.LinkedList
import java.util.concurrent.CompletableFuture
import java.util.function.Consumer import java.util.function.Consumer
@Suppress("unused") @Suppress("unused")
open class AndroidResearchDataProvider() : DataProvider { open class AndroidResearchDataProvider() : DataProvider {
var pathProvider: PackOutput.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider") var pathProvider: DataGenerator.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider")
private set private set
constructor(output: PackOutput) : this() { constructor(output: DataGenerator) : this() {
bindPackOutput(output) bindPackOutput(output)
} }
constructor(event: GatherDataEvent) : this(event.generator.packOutput) constructor(event: GatherDataEvent) : this(event.generator)
fun bindPackOutput(output: PackOutput) { fun bindPackOutput(output: DataGenerator) {
pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, AndroidResearchManager.DIRECTORY) pathProvider = output.createPathProvider(DataGenerator.Target.DATA_PACK, AndroidResearchManager.DIRECTORY)
} }
protected val callbacks = LinkedList<(Consumer<AndroidResearchType>) -> Unit>() protected val callbacks = LinkedList<(Consumer<AndroidResearchType>) -> Unit>()
@ -52,14 +50,13 @@ open class AndroidResearchDataProvider() : DataProvider {
return this return this
} }
final override fun run(output: CachedOutput): CompletableFuture<*> { final override fun run(output: CachedOutput) {
val set = ObjectArraySet<ResourceLocation>() val set = ObjectArraySet<ResourceLocation>()
val added = LinkedList<AndroidResearchType>() val added = LinkedList<AndroidResearchType>()
val futures = ArrayList<CompletableFuture<*>>()
addEverything { addEverything {
if (set.add(it.id)) { if (set.add(it.id)) {
futures.add(DataProvider.saveStable(output, AndroidResearchType.CODEC.toJsonStrict(it).also { (it as JsonObject).remove("id") }, pathProvider.json(it.id))) DataProvider.saveStable(output, AndroidResearchType.CODEC.toJsonStrict(it).also { (it as JsonObject).remove("id") }, pathProvider.json(it.id))
AndroidResearchManager.put(it) AndroidResearchManager.put(it)
added.add(it) added.add(it)
} else { } else {
@ -71,8 +68,6 @@ open class AndroidResearchDataProvider() : DataProvider {
value.validate() value.validate()
generated.add(value) generated.add(value)
} }
return CompletableFuture.allOf(*futures.toTypedArray())
} }
override fun getName(): String { override fun getName(): String {

View File

@ -36,7 +36,6 @@ import ru.dbotthepony.mc.otm.client.render.linesIgnoreZRenderType
import ru.dbotthepony.mc.otm.client.render.sprites.sprite import ru.dbotthepony.mc.otm.client.render.sprites.sprite
import ru.dbotthepony.mc.otm.config.AndroidConfig import ru.dbotthepony.mc.otm.config.AndroidConfig
import ru.dbotthepony.mc.otm.core.genericPositions import ru.dbotthepony.mc.otm.core.genericPositions
import ru.dbotthepony.mc.otm.core.holder
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.Vector
import ru.dbotthepony.mc.otm.core.math.asVector import ru.dbotthepony.mc.otm.core.math.asVector
@ -301,7 +300,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5) val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
if (event.isCanceled) { if (event.isCanceled) {
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong())) (ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
return false return false
} }

View File

@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.capability.energy.WorkerEnergyStorage
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.config.MachinesConfig import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid import ru.dbotthepony.mc.otm.core.getEntitiesInEllipsoid
import ru.dbotthepony.mc.otm.core.math.center
import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu import ru.dbotthepony.mc.otm.menu.tech.AndroidChargerMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities import ru.dbotthepony.mc.otm.registry.MBlockEntities

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.capability
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Vector4f
import it.unimi.dsi.fastutil.ints.IntAVLTreeSet import it.unimi.dsi.fastutil.ints.IntAVLTreeSet
import it.unimi.dsi.fastutil.ints.IntSet import it.unimi.dsi.fastutil.ints.IntSet
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
@ -61,7 +62,6 @@ import net.minecraftforge.network.PacketDistributor
import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.ForgeRegistries
import net.minecraftforge.server.command.EnumArgument import net.minecraftforge.server.command.EnumArgument
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.joml.Vector4f
import ru.dbotthepony.mc.otm.* import ru.dbotthepony.mc.otm.*
import ru.dbotthepony.mc.otm.android.AndroidFeature import ru.dbotthepony.mc.otm.android.AndroidFeature
import ru.dbotthepony.mc.otm.android.AndroidFeatureType import ru.dbotthepony.mc.otm.android.AndroidFeatureType
@ -1415,9 +1415,9 @@ class MatteryPlayerCapability(val ply: Player) : ICapabilityProvider, INBTSerial
val pos = Vector4f(model.body.x / 16f, model.body.y / 16f, model.body.z / 16f, 1f) val pos = Vector4f(model.body.x / 16f, model.body.y / 16f, model.body.z / 16f, 1f)
val cam = minecraft.gameRenderer.mainCamera.position val cam = minecraft.gameRenderer.mainCamera.position
pos.mul(RenderSystem.getProjectionMatrix()) pos.transform(RenderSystem.getProjectionMatrix())
pos.mul(poseStack.last().pose()) pos.transform(poseStack.last().pose())
makeSmoke(cam.x + pos.x, cam.y + pos.y, cam.z + pos.z, ply.level.random, ply.level) makeSmoke(cam.x + pos.x(), cam.y + pos.y(), cam.z + pos.z(), ply.level.random, ply.level)
} }
} }

View File

@ -9,7 +9,6 @@ import it.unimi.dsi.fastutil.objects.ReferenceArraySet
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.Sheets import net.minecraft.client.renderer.Sheets
import org.joml.Vector3f
private fun equals(existing: ImmutableList<RenderType>?, types: Array<out RenderType>): Boolean { private fun equals(existing: ImmutableList<RenderType>?, types: Array<out RenderType>): Boolean {
if (types.isEmpty()) { if (types.isEmpty()) {

View File

@ -1,11 +1,11 @@
package ru.dbotthepony.mc.otm.client.render package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Matrix4f
import net.minecraft.client.gui.Font import net.minecraft.client.gui.Font
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import net.minecraft.util.FormattedCharSequence import net.minecraft.util.FormattedCharSequence
import org.joml.Matrix4f
import ru.dbotthepony.mc.otm.core.FloatSupplier import ru.dbotthepony.mc.otm.core.FloatSupplier
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component1

View File

@ -5,12 +5,12 @@ import com.mojang.blaze3d.platform.GlConst
import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.FogRenderer import net.minecraft.client.renderer.FogRenderer
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import net.minecraft.world.level.material.FogType import net.minecraft.world.level.material.FogType
import org.joml.Matrix4f
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft

View File

@ -6,9 +6,6 @@ import com.mojang.blaze3d.vertex.VertexConsumer
import com.mojang.math.Matrix4f import com.mojang.math.Matrix4f
import com.mojang.math.Vector3f import com.mojang.math.Vector3f
import net.minecraft.core.Vec3i import net.minecraft.core.Vec3i
import org.joml.Matrix4f
import org.joml.Quaternionf
import org.joml.Vector3f
import ru.dbotthepony.mc.otm.core.math.IAngle import ru.dbotthepony.mc.otm.core.math.IAngle
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.Vector
@ -36,7 +33,7 @@ fun PoseStack.translate(vector: Vector3f) = translate(vector.x(), vector.y(), ve
fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
val last = last() val last = last()
last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) last.pose().rotateAroundPoint(point, axis, rotation, isDegrees)
last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) last.normal().mul(axis.rotateAroundThis(rotation, isDegrees))
} }
fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) { fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) {
@ -48,7 +45,7 @@ fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) {
fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
val last = last() val last = last()
last.pose().rotateAroundPoint(point, axis, rotation, isDegrees) last.pose().rotateAroundPoint(point, axis, rotation, isDegrees)
last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees)) last.normal().mul(axis.rotateAroundThis(rotation, isDegrees))
} }
fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) { fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) {
@ -57,10 +54,11 @@ fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) {
// last.normal().mul(rotation.forward().rotateAroundThis(rotation)) // last.normal().mul(rotation.forward().rotateAroundThis(rotation))
} }
fun PoseStack.rotateAround(rotationMatrix: Quaternionf, x: Float, y: Float, z: Float) { fun PoseStack.rotateAround(axis: Vector3f, radians: Float) {
val q = axis.rotation(radians)
val pose = last val pose = last
pose.pose.rotateAround(rotationMatrix, x, y, z) pose.pose.multiply(q)
pose.normal().rotate(rotationMatrix) pose.normal().mul(q)
} }
fun PoseStack.translation(): Vector3f { fun PoseStack.translation(): Vector3f {

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.RenderStateShard import net.minecraft.client.renderer.RenderStateShard
import net.minecraft.client.renderer.RenderStateShard.LineStateShard import net.minecraft.client.renderer.RenderStateShard.LineStateShard
@ -11,7 +12,6 @@ import net.minecraft.client.renderer.ShaderInstance
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.server.packs.resources.ResourceProvider import net.minecraft.server.packs.resources.ResourceProvider
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.joml.Matrix4f
import org.lwjgl.opengl.GL11.GL_ALWAYS import org.lwjgl.opengl.GL11.GL_ALWAYS
import org.lwjgl.opengl.GL11.GL_LESS import org.lwjgl.opengl.GL11.GL_LESS
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
@ -92,6 +92,7 @@ fun renderRect(
tess.end() tess.end()
} }
@OptIn(ExperimentalStdlibApi::class)
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
fun renderCheckerboard( fun renderCheckerboard(
matrix: Matrix4f, matrix: Matrix4f,

View File

@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.block.entity.tech.BatteryBankBlockEntity
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite import ru.dbotthepony.mc.otm.client.render.sprites.AbstractMatterySprite
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.translate
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.immutableList import ru.dbotthepony.mc.otm.core.immutableList

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.Minecraft import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
@ -9,7 +10,6 @@ import net.minecraft.client.renderer.blockentity.BeaconRenderer
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.world.phys.Vec3 import net.minecraft.world.phys.Vec3
import org.joml.Matrix4f
import org.lwjgl.opengl.GL30 import org.lwjgl.opengl.GL30
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity
@ -25,6 +25,7 @@ import ru.dbotthepony.mc.otm.core.math.VECTOR_UP
import ru.dbotthepony.mc.otm.core.math.Vector import ru.dbotthepony.mc.otm.core.math.Vector
import ru.dbotthepony.mc.otm.core.math.asMutableAngle import ru.dbotthepony.mc.otm.core.math.asMutableAngle
import ru.dbotthepony.mc.otm.core.math.asVector import ru.dbotthepony.mc.otm.core.math.asVector
import ru.dbotthepony.mc.otm.core.math.length
import ru.dbotthepony.mc.otm.core.math.minus import ru.dbotthepony.mc.otm.core.math.minus
import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis import ru.dbotthepony.mc.otm.core.math.rotateAroundAxis
import ru.dbotthepony.mc.otm.core.math.times import ru.dbotthepony.mc.otm.core.math.times

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.render.blockentity package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import com.mojang.math.Axis import com.mojang.math.Vector3f
import net.minecraft.client.renderer.* import net.minecraft.client.renderer.*
import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.block.model.ItemTransforms
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
@ -19,7 +19,9 @@ import net.minecraftforge.fluids.capability.IFluidHandler
import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity
import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.rotateAround import ru.dbotthepony.mc.otm.client.render.rotateAround
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.core.ifPresentK import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.core.math.PIf
import ru.dbotthepony.mc.otm.core.math.RGBAColor import ru.dbotthepony.mc.otm.core.math.RGBAColor
import ru.dbotthepony.mc.otm.core.math.linearInterpolation import ru.dbotthepony.mc.otm.core.math.linearInterpolation
import ru.dbotthepony.mc.otm.registry.MBlocks import ru.dbotthepony.mc.otm.registry.MBlocks
@ -107,7 +109,7 @@ class FluidTankRenderer(private val context: BlockEntityRendererProvider.Context
poseStack.pushPose() poseStack.pushPose()
poseStack.translate(0.5, 0.0, 0.5) poseStack.translate(0.5, 0.0, 0.5)
poseStack.rotateAround(Axis.YP.rotationDegrees(i * 90.0f), 0.0f, 1.0f, 0.0f) poseStack.rotateAround(Vector3f.YP, PIf / 2f * i)
poseStack.translate(-0.5f, 0f, fluidWidth * .5f) poseStack.translate(-0.5f, 0f, fluidWidth * .5f)
val matrix = poseStack.last().pose() val matrix = poseStack.last().pose()

View File

@ -2,6 +2,7 @@
package ru.dbotthepony.mc.otm.client.render.blockentity package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.vertex.* import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.blockentity.BeaconRenderer import net.minecraft.client.renderer.blockentity.BeaconRenderer
@ -9,7 +10,6 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
import net.minecraft.client.renderer.texture.OverlayTexture import net.minecraft.client.renderer.texture.OverlayTexture
import net.minecraft.core.Direction import net.minecraft.core.Direction
import org.joml.Matrix4f
import ru.dbotthepony.mc.otm.core.TranslatableComponent import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.block.BlackHoleBlock import ru.dbotthepony.mc.otm.block.BlackHoleBlock
import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity import ru.dbotthepony.mc.otm.block.entity.tech.GravitationStabilizerBlockEntity

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.render.blockentity package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Axis import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.block.model.ItemTransforms
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
@ -29,8 +29,8 @@ class MatterReconstructorRenderer(private val context: BlockEntityRendererProvid
pose.translate(0.5, 0.6, 0.5) pose.translate(0.5, 0.6, 0.5)
pose.scale(0.5f, 0.5f, 0.5f) pose.scale(0.5f, 0.5f, 0.5f)
pose.mulPose(Axis.XP.rotationDegrees(90f)) pose.mulPose(Vector3f.XP.rotationDegrees(90f))
pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot())) pose.mulPose(Vector3f.ZP.rotationDegrees(tile.blockRotation.back.toYRot()))
context.itemRenderer.renderStatic(item, ItemTransforms.TransformType.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.blockPos.asLong().toInt()) context.itemRenderer.renderStatic(item, ItemTransforms.TransformType.FIXED, packedLight, packedOverlay, pose, DynamicBufferSource.WORLD, tile.blockPos.asLong().toInt())

View File

@ -4,13 +4,13 @@ import com.mojang.blaze3d.platform.GlStateManager.DestFactor
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor import com.mojang.blaze3d.platform.GlStateManager.SourceFactor
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.block.model.ItemTransforms
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.particles.DustParticleOptions import net.minecraft.core.particles.DustParticleOptions
import net.minecraft.world.level.levelgen.XoroshiroRandomSource import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import org.joml.Vector3f
import org.lwjgl.opengl.GL14.glBlendColor import org.lwjgl.opengl.GL14.glBlendColor
import ru.dbotthepony.mc.otm.block.entity.WorkerState import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity

View File

@ -3,7 +3,7 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.platform.GlStateManager import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Axis import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.block.model.ItemTransforms import net.minecraft.client.renderer.block.model.ItemTransforms
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
@ -36,8 +36,8 @@ class MatterScannerRenderer(private val context: BlockEntityRendererProvider.Con
pose.translate(0.5, 0.5, 0.5) pose.translate(0.5, 0.5, 0.5)
pose.scale(0.5f, 0.5f, 0.5f) pose.scale(0.5f, 0.5f, 0.5f)
pose.mulPose(Axis.XP.rotationDegrees(90f)) pose.mulPose(Vector3f.XP.rotationDegrees(90f))
pose.mulPose(Axis.ZP.rotationDegrees(tile.blockRotation.back.toYRot())) pose.mulPose(Vector3f.ZP.rotationDegrees(tile.blockRotation.back.toYRot()))
context.itemRenderer.renderStatic( context.itemRenderer.renderStatic(
item, item,

View File

@ -1,7 +1,7 @@
package ru.dbotthepony.mc.otm.client.render.entity package ru.dbotthepony.mc.otm.client.render.entity
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Axis import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.RenderType import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.client.renderer.entity.EntityRenderer
@ -27,7 +27,7 @@ class PlasmaProjectileRenderer(context: EntityRendererProvider.Context) : Entity
poseStack.pushPose() poseStack.pushPose()
poseStack.mulPose(entityRenderDispatcher.cameraOrientation()) poseStack.mulPose(entityRenderDispatcher.cameraOrientation())
poseStack.mulPose(Axis.YP.rotationDegrees(180f)) poseStack.mulPose(Vector3f.YP.rotationDegrees(180f))
poseStack.scale(.3f, .3f, .3f) poseStack.scale(.3f, .3f, .3f)
val matrix = poseStack.last().pose() val matrix = poseStack.last().pose()

View File

@ -12,7 +12,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap
import net.minecraft.client.gui.screens.Screen import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.renderer.GameRenderer import net.minecraft.client.renderer.GameRenderer
import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component
import org.joml.Vector2i
import ru.dbotthepony.mc.otm.client.render.MGUIGraphics import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.isCtrlDown import ru.dbotthepony.mc.otm.client.isCtrlDown
import ru.dbotthepony.mc.otm.client.isShiftDown import ru.dbotthepony.mc.otm.client.isShiftDown
@ -21,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.RenderGravity import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.tesselator import ru.dbotthepony.mc.otm.client.render.tesselator
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty import ru.dbotthepony.mc.otm.client.screen.panels.DockProperty
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.TextComponent import ru.dbotthepony.mc.otm.core.TextComponent
@ -32,6 +32,8 @@ import ru.dbotthepony.mc.otm.milliTime
import java.util.function.Predicate import java.util.function.Predicate
import kotlin.math.roundToInt import kotlin.math.roundToInt
data class Vector2i(val x: Int, val y: Int)
open class TextInputPanel<out S : Screen>( open class TextInputPanel<out S : Screen>(
screen: S, screen: S,
parent: EditablePanel<*>?, parent: EditablePanel<*>?,

View File

@ -80,6 +80,3 @@ val Fluid.registryName get() = ForgeRegistries.FLUIDS.getKeyNullable(this)
val Block.registryName get() = ForgeRegistries.BLOCKS.getKeyNullable(this) val Block.registryName get() = ForgeRegistries.BLOCKS.getKeyNullable(this)
fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistries.ITEMS, value) fun FriendlyByteBuf.writeRegistryId(value: Item) = writeRegistryId(ForgeRegistries.ITEMS, value)
// 1.19.3 lol
inline val SoundEvent.holder get() = ForgeRegistries.SOUND_EVENTS.getHolder(this).orElse(null) ?: throw NoSuchElementException("$this is missing from ${ForgeRegistries.SOUND_EVENTS}")

View File

@ -1,24 +1,20 @@
package ru.dbotthepony.mc.otm.core.math package ru.dbotthepony.mc.otm.core.math
import com.mojang.blaze3d.vertex.PoseStack import com.mojang.blaze3d.vertex.PoseStack
import it.unimi.dsi.fastutil.ints.IntSpliterators import com.mojang.math.Matrix3f
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap import com.mojang.math.Matrix4f
import com.mojang.math.Quaternion
import com.mojang.math.Vector3f
import net.minecraft.core.BlockPos 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.world.phys.Vec3 import net.minecraft.world.phys.Vec3
import org.joml.AxisAngle4f import ru.dbotthepony.mc.otm.client.render.translate
import org.joml.Matrix3f
import org.joml.Matrix4f
import org.joml.Quaternionf
import org.joml.Vector3f
import ru.dbotthepony.mc.otm.core.collect.filter import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.flatMap import ru.dbotthepony.mc.otm.core.collect.flatMap
import ru.dbotthepony.mc.otm.core.collect.map import ru.dbotthepony.mc.otm.core.collect.map
import java.lang.ref.SoftReference
import java.util.stream.Stream
import java.util.stream.StreamSupport
import kotlin.math.* import kotlin.math.*
import ru.dbotthepony.mc.otm.core.math.set
typealias Vector = Vec3 typealias Vector = Vec3
@ -45,6 +41,8 @@ fun Vector.asMutableAngle(): MutableAngle {
return MutableAngle(asin(norm.y), atan2(norm.x, norm.z)) return MutableAngle(asin(norm.y), atan2(norm.x, norm.z))
} }
fun Vector3f.length() = sqrt(x() * x() + y() * y() + z() * z())
fun Vector3f.asAngle(): Angle { fun Vector3f.asAngle(): Angle {
val len = length().toDouble() val len = length().toDouble()
val norm = Vector(x() / len, y() / len, z() / len) val norm = Vector(x() / len, y() / len, z() / len)
@ -57,20 +55,10 @@ fun Vector3f.asMutableAngle(): MutableAngle {
return MutableAngle(asin(norm.y), atan2(norm.x, norm.z)) return MutableAngle(asin(norm.y), atan2(norm.x, norm.z))
} }
fun Vector3f.rotation(radians: Float): Quaternionf {
return Quaternionf(AxisAngle4f(radians, x, y, z))
}
fun Vector3f.rotationDegrees(degrees: Float): Quaternionf {
return rotation(toRadians(degrees))
}
operator fun Vector3f.unaryMinus(): Vector3f { operator fun Vector3f.unaryMinus(): Vector3f {
return Vector3f(-x, -y, -z) return Vector3f(-x(), -y(), -z())
} }
operator fun Vector3f.times(v: Float): Vector3f = Vector3f(v).mul(v)
operator fun Vector3f.component1() = x() operator fun Vector3f.component1() = x()
operator fun Vector3f.component2() = y() operator fun Vector3f.component2() = y()
operator fun Vector3f.component3() = z() operator fun Vector3f.component3() = z()
@ -79,6 +67,8 @@ operator fun Vec3i.component1() = x
operator fun Vec3i.component2() = y operator fun Vec3i.component2() = y
operator fun Vec3i.component3() = z operator fun Vec3i.component3() = z
inline val Vec3i.center get() = Vector(x + 0.5, y + 0.5, z + 0.5)
fun Vec3i.toDoubleVector() = Vector(x.toDouble(), y.toDouble(), z.toDouble()) fun Vec3i.toDoubleVector() = Vector(x.toDouble(), y.toDouble(), z.toDouble())
fun shortestDistanceBetween(a: Collection<Vector>, b: Collection<Vector>): Double { fun shortestDistanceBetween(a: Collection<Vector>, b: Collection<Vector>): Double {
@ -144,14 +134,8 @@ fun Vector.asVector3f(): Vector3f {
return Vector3f(x.toFloat(), y.toFloat(), z.toFloat()) return Vector3f(x.toFloat(), y.toFloat(), z.toFloat())
} }
fun Quaternion(vec: Vector, rotation: Float, isDegrees: Boolean = false): Quaternionf { fun Quaternion(vec: Vector, rotation: Float, isDegrees: Boolean = false): Quaternion {
// TODO: 1.19.3 return Quaternion(vec.asVector3f(), rotation, isDegrees)
return Quaternionf(AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, vec.x.toFloat(), vec.y.toFloat(), vec.z.toFloat()))
}
fun AxisAngle4f(vec: Vector, rotation: Float, isDegrees: Boolean = false): AxisAngle4f {
// TODO: 1.19.3
return AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, vec.x.toFloat(), vec.y.toFloat(), vec.z.toFloat())
} }
fun Vector(x: Double): Vector { fun Vector(x: Double): Vector {
@ -162,24 +146,17 @@ fun Vector(x: Double, y: Double): Vector {
return Vector(x, y, 0.0) return Vector(x, y, 0.0)
} }
fun Vector.rotate(q: Quaternionf): Vector { fun Vector.rotate(q: Quaternion): Vector {
// TODO: 1.19.3 val quaternion = Quaternion(q)
val quaternion = Quaternionf(q) quaternion.mul(Quaternion(x.toFloat(), y.toFloat(), z.toFloat(), 0.0f))
quaternion.mul(rotateAroundThis()) val quaternion1 = Quaternion(q)
val quaternion1 = Quaternionf(q) quaternion1.conj()
quaternion1.conjugate()
quaternion.mul(quaternion1) quaternion.mul(quaternion1)
return Vector(quaternion.x.toDouble(), quaternion.y.toDouble(), quaternion.z.toDouble()) return Vector(quaternion.i().toDouble(), quaternion.j().toDouble(), quaternion.k().toDouble())
} }
fun Vector.rotateAroundThis(rotation: Float, isDegrees: Boolean = false): Quaternionf { fun Vector.rotateAroundThis(rotation: Float, isDegrees: Boolean = false): Quaternion {
// TODO: 1.19.3 return Quaternion(this, rotation, isDegrees)
return Quaternionf(AxisAngle4f(if (isDegrees) toRadians(rotation) else rotation, x.toFloat(), y.toFloat(), z.toFloat()))
}
fun Vector.rotateAroundThis(): Quaternionf {
// TODO: 1.19.3
return Quaternionf(AxisAngle4f(0f, x.toFloat(), y.toFloat(), z.toFloat()))
} }
fun Vector.asMatrix(): Matrix3f { fun Vector.asMatrix(): Matrix3f {
@ -221,13 +198,13 @@ interface IAngle {
val s = sin(roll).toFloat() val s = sin(roll).toFloat()
val c = cos(roll).toFloat() val c = cos(roll).toFloat()
it[0, 0] = 1f it.mset(0, 0, 1f)
it[1, 1] = c it.mset(1, 1, c)
it[2, 1] = -s it.mset(2, 1, -s)
it[1, 2] = s it.mset(1, 2, s)
it[2, 2] = c it.mset(2, 2, c)
} }
} }
@ -240,13 +217,13 @@ interface IAngle {
val s = sin(pitch).toFloat() val s = sin(pitch).toFloat()
val c = cos(pitch).toFloat() val c = cos(pitch).toFloat()
it[0, 0] = c it.mset(0, 0, c)
it[1, 0] = -s it.mset(1, 0, -s)
it[0, 1] = s it.mset(0, 1, s)
it[1, 1] = c it.mset(1, 1, c)
it[2, 2] = 1f it.mset(2, 2, 1f)
} }
} }
@ -259,13 +236,13 @@ interface IAngle {
val s = sin(yaw).toFloat() val s = sin(yaw).toFloat()
val c = cos(yaw).toFloat() val c = cos(yaw).toFloat()
it[0, 0,] = c it.mset(0, 0, c)
it[2, 0,] = s it.mset(2, 0, s)
it[0, 2,] = -s it.mset(0, 2, -s)
it[2, 2,] = c it.mset(2, 2, c)
it[1, 1,] = 1f it.mset(1, 1, 1f)
} }
} }
@ -513,17 +490,17 @@ fun angleDifferenceDeg(angle1: Float, angle2: Float): Float {
// 1.19.3 stuff // 1.19.3 stuff
fun PoseStack.rotateY(rotation: Float): PoseStack { fun PoseStack.rotateY(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 1f, 0f))) mulPose(Vector3f.YP.rotation(rotation))
return this return this
} }
fun PoseStack.rotateX(rotation: Float): PoseStack { fun PoseStack.rotateX(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 1f, 0f, 0f))) mulPose(Vector3f.XP.rotation(rotation))
return this return this
} }
fun PoseStack.rotateZ(rotation: Float): PoseStack { fun PoseStack.rotateZ(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 0f, 1f))) mulPose(Vector3f.ZP.rotation(rotation))
return this return this
} }
@ -627,17 +604,17 @@ fun PoseStack.rotateWithBlockFacing(rotation: BlockRotation): PoseStack {
} }
fun PoseStack.rotateYDegrees(rotation: Float): PoseStack { fun PoseStack.rotateYDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 1f, 0f))) mulPose(Vector3f.YP.rotationDegrees(rotation))
return this return this
} }
fun PoseStack.rotateXDegrees(rotation: Float): PoseStack { fun PoseStack.rotateXDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 1f, 0f, 0f))) mulPose(Vector3f.XP.rotationDegrees(rotation))
return this return this
} }
fun PoseStack.rotateZDegrees(rotation: Float): PoseStack { fun PoseStack.rotateZDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 0f, 1f))) mulPose(Vector3f.ZP.rotationDegrees(rotation))
return this return this
} }

View File

@ -3,20 +3,13 @@
package ru.dbotthepony.mc.otm.core.math package ru.dbotthepony.mc.otm.core.math
import org.joml.Matrix3f import com.mojang.math.Matrix3f
import org.joml.Matrix4f import com.mojang.math.Matrix4f
import org.joml.Vector3f import com.mojang.math.Vector3f
import org.joml.Vector4f import com.mojang.math.Vector4f
import ru.dbotthepony.mc.otm.core.math.IAngle
import ru.dbotthepony.mc.otm.core.math.Vector
import ru.dbotthepony.mc.otm.core.math.asVector3f
import ru.dbotthepony.mc.otm.core.math.rotateAroundThis
import ru.dbotthepony.mc.otm.core.math.rotation
import ru.dbotthepony.mc.otm.core.math.rotationDegrees
import ru.dbotthepony.mc.otm.core.math.unaryMinus
fun Matrix4f.rotate(angle: IAngle): Matrix4f { fun Matrix4f.rotate(angle: IAngle): Matrix4f {
mul(angle.rotationXYZW()) multiply(angle.rotationXYZW())
return this return this
} }
@ -27,56 +20,160 @@ fun Matrix4f.translate(vector: Vector) {
fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) { fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
val p = point.asVector3f() val p = point.asVector3f()
translate(-p) translate(-p)
rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 multiply(axis.rotateAroundThis(rotation, isDegrees))
translate(p) translate(-p)
} }
fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { fun Matrix4f.rotateAroundPoint(point: Vector, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) {
val p = point.asVector3f() val p = point.asVector3f()
translate(-p) translate(-p)
rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 multiply(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation))
translate(p) translate(-p)
} }
fun Matrix4f.rotateAroundPoint(point: Vector, rotation: IAngle) { fun Matrix4f.rotateAroundPoint(point: Vector, rotation: IAngle) {
val p = point.asVector3f() val p = point.asVector3f()
translate(-p) translate(-p)
mul(rotation.rotationXYZW()) multiply(rotation.rotationXYZW())
translate(p) translate(-p)
} }
fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) { fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
translate(-point) translate(-point)
rotation(axis.rotateAroundThis(rotation, isDegrees)) // TODO: 1.19.3 multiply(axis.rotateAroundThis(rotation, isDegrees))
translate(point) translate(-point)
} }
fun Matrix4f.rotateAroundPoint(point: Vector3f, rotation: IAngle) { fun Matrix4f.rotateAroundPoint(point: Vector3f, rotation: IAngle) {
translate(-point) translate(-point)
mul(rotation.rotationXYZW()) multiply(rotation.rotationXYZW())
translate(point) translate(-point)
} }
fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) { fun Matrix4f.rotateAroundPoint(point: Vector3f, axis: Vector3f, rotation: Float, isDegrees: Boolean = false) {
translate(-point) translate(-point)
rotation(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation)) // TODO: 1.19.3 multiply(if (isDegrees) axis.rotationDegrees(rotation) else axis.rotation(rotation))
translate(point) translate(-point)
}
// 1.19.3 <-> 1.19.2 behavior
// mojang decided it is a good idea to make their matrices row-major
// when basically everyone else (well, aside from thing nobody uses, what is it called, uuuuuuuugh directx i think)
// uses column-major matrices
operator fun Matrix4f.get(column: Int, row: Int): Float {
require(row in 0 .. 3) { "Invalid row: $row" }
require(column in 0 .. 3) { "Invalid column: $column" }
return when (val index = row or (column shl 2)) {
0 or (0 shl 2) -> m00
1 or (0 shl 2) -> m10
2 or (0 shl 2) -> m20
3 or (0 shl 2) -> m30
0 or (1 shl 2) -> m01
1 or (1 shl 2) -> m11
2 or (1 shl 2) -> m21
3 or (1 shl 2) -> m31
0 or (2 shl 2) -> m02
1 or (2 shl 2) -> m12
2 or (2 shl 2) -> m22
3 or (2 shl 2) -> m32
0 or (3 shl 2) -> m03
1 or (3 shl 2) -> m13
2 or (3 shl 2) -> m23
3 or (3 shl 2) -> m33
else -> throw IllegalStateException("$index")
}
}
operator fun Matrix4f.set(column: Int, row: Int, value: Float) {
require(row in 0 .. 3) { "Invalid row: $row" }
require(column in 0 .. 3) { "Invalid column: $column" }
when (val index = row or (column shl 2)) {
0 or (0 shl 2) -> m00 = value
1 or (0 shl 2) -> m10 = value
2 or (0 shl 2) -> m20 = value
3 or (0 shl 2) -> m30 = value
0 or (1 shl 2) -> m01 = value
1 or (1 shl 2) -> m11 = value
2 or (1 shl 2) -> m21 = value
3 or (1 shl 2) -> m31 = value
0 or (2 shl 2) -> m02 = value
1 or (2 shl 2) -> m12 = value
2 or (2 shl 2) -> m22 = value
3 or (2 shl 2) -> m32 = value
0 or (3 shl 2) -> m03 = value
1 or (3 shl 2) -> m13 = value
2 or (3 shl 2) -> m23 = value
3 or (3 shl 2) -> m33 = value
else -> throw IllegalStateException("$index")
}
}
operator fun Matrix3f.get(column: Int, row: Int): Float {
require(row in 0 .. 2) { "Invalid row: $row" }
require(column in 0 .. 2) { "Invalid column: $column" }
return when (val index = row or (column shl 2)) {
0 or (0 shl 2) -> m00
1 or (0 shl 2) -> m10
2 or (0 shl 2) -> m20
0 or (1 shl 2) -> m01
1 or (1 shl 2) -> m11
2 or (1 shl 2) -> m21
0 or (2 shl 2) -> m02
1 or (2 shl 2) -> m12
2 or (2 shl 2) -> m22
else -> throw IllegalStateException("$index")
}
}
fun Matrix3f.mset(column: Int, row: Int, value: Float) {
require(row in 0 .. 2) { "Invalid row: $row" }
require(column in 0 .. 2) { "Invalid column: $column" }
when (val index = row or (column shl 2)) {
0 or (0 shl 2) -> m00 = value
1 or (0 shl 2) -> m10 = value
2 or (0 shl 2) -> m20 = value
0 or (1 shl 2) -> m01 = value
1 or (1 shl 2) -> m11 = value
2 or (1 shl 2) -> m21 = value
0 or (2 shl 2) -> m02 = value
1 or (2 shl 2) -> m12 = value
2 or (2 shl 2) -> m22 = value
else -> throw IllegalStateException("$index")
}
}
fun Matrix4f.identity() = setIdentity()
fun Matrix3f.identity() = setIdentity()
fun Matrix4f.identityFast() {
m00 = 1.0F
m11 = 1.0F
m22 = 1.0F
m33 = 1.0F
}
fun Matrix3f.identityFast() {
m00 = 1.0F
m11 = 1.0F
m22 = 1.0F
} }
fun Matrix3f.toMatrix4f(): Matrix4f { fun Matrix3f.toMatrix4f(): Matrix4f {
val result = Matrix4f() val result = Matrix4f()
result.zero() result.m00 = this.m00
result.m10 = this.m10
result.m00(this.m00) result.m20 = this.m20
result.m10(this.m10) result.m01 = this.m01
result.m20(this.m20) result.m11 = this.m11
result.m01(this.m01) result.m21 = this.m21
result.m11(this.m11) result.m02 = this.m02
result.m21(this.m21) result.m12 = this.m12
result.m02(this.m02) result.m22 = this.m22
result.m12(this.m12)
result.m22(this.m22)
return result return result
} }

View File

@ -91,7 +91,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition()) val (ex, ey, ez) = Vector.atCenterOf(player.blockPosition())
val exp = Explosion(player.level, player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP) val exp = Explosion(player.level, player, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.BREAK else Explosion.BlockInteraction.NONE)
exp.explode() exp.explode()
exp.finalizeExplosion(true) exp.finalizeExplosion(true)

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.matter
import com.mojang.datafixers.util.Either import com.mojang.datafixers.util.Either
import net.minecraft.data.CachedOutput import net.minecraft.data.CachedOutput
import net.minecraft.data.DataGenerator
import net.minecraft.data.DataProvider import net.minecraft.data.DataProvider
import net.minecraft.resources.ResourceLocation import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.TagKey import net.minecraft.tags.TagKey
@ -21,17 +22,17 @@ import kotlin.collections.LinkedHashMap
@Suppress("FunctionName", "unused") @Suppress("FunctionName", "unused")
open class MatterDataProvider(val modid: String? = null) : DataProvider { open class MatterDataProvider(val modid: String? = null) : DataProvider {
var pathProvider: PackOutput.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider") var pathProvider: DataGenerator.PathProvider by WriteOnce("You need to call bindPackOutput before registering this data provider")
private set private set
constructor(output: PackOutput, modid: String? = null) : this(modid) { constructor(output: DataGenerator, modid: String? = null) : this(modid) {
bindPackOutput(output) bindPackOutput(output)
} }
constructor(event: GatherDataEvent) : this(event.generator.packOutput, event.modContainer.namespace) constructor(event: GatherDataEvent) : this(event.generator, event.modContainer.namespace)
fun bindPackOutput(output: PackOutput) { fun bindPackOutput(output: DataGenerator) {
pathProvider = output.createPathProvider(PackOutput.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY) pathProvider = output.createPathProvider(DataGenerator.Target.DATA_PACK, MatterManager.MATTER_DIRECTORY)
} }
protected val actions = LinkedHashMap<ResourceLocation, AbstractRegistryAction>() protected val actions = LinkedHashMap<ResourceLocation, AbstractRegistryAction>()
@ -1255,17 +1256,13 @@ open class MatterDataProvider(val modid: String? = null) : DataProvider {
protected val added = ArrayList<AbstractRegistryAction>() protected val added = ArrayList<AbstractRegistryAction>()
val addedView: List<AbstractRegistryAction> = Collections.unmodifiableList(added) val addedView: List<AbstractRegistryAction> = Collections.unmodifiableList(added)
final override fun run(output: CachedOutput): CompletableFuture<*> { final override fun run(output: CachedOutput) {
addActions() addActions()
val promises = ArrayList<CompletableFuture<*>>()
for ((key, value) in actions) { for ((key, value) in actions) {
promises.add(DataProvider.saveStable(output, AbstractRegistryAction.CODEC.toJsonStrict(value), pathProvider.json(key))) DataProvider.saveStable(output, AbstractRegistryAction.CODEC.toJsonStrict(value), pathProvider.json(key))
added.add(value) added.add(value)
} }
return CompletableFuture.allOf(*promises.toTypedArray())
} }
override fun getName(): String { override fun getName(): String {

View File

@ -39,7 +39,7 @@ public net.minecraft.client.gui.GuiComponent m_93179_(Lcom/mojang/blaze3d/vertex
public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG public net.minecraft.world.item.BlockItem f_150696_ # BLOCK_ENTITY_TAG
public net.minecraft.client.gui.screens.InBedChatScreen f_263129_ # leaveBedButton public net.minecraft.client.gui.screens.InBedChatScreen f_242488_ # leaveBedButton
public net.minecraft.world.inventory.AbstractContainerMenu f_182405_ # stateId public net.minecraft.world.inventory.AbstractContainerMenu f_182405_ # stateId
@ -57,6 +57,33 @@ protected net.minecraft.client.resources.TextureAtlasHolder f_118884_ # textureA
public net.minecraft.client.renderer.RenderStateShard f_110133_ # name public net.minecraft.client.renderer.RenderStateShard f_110133_ # name
public com.mojang.math.Matrix4f f_27603_ # m00
public com.mojang.math.Matrix4f f_27604_ # m01
public com.mojang.math.Matrix4f f_27605_ # m02
public com.mojang.math.Matrix4f f_27606_ # m03
public com.mojang.math.Matrix4f f_27607_ # m10
public com.mojang.math.Matrix4f f_27608_ # m11
public com.mojang.math.Matrix4f f_27609_ # m12
public com.mojang.math.Matrix4f f_27610_ # m13
public com.mojang.math.Matrix4f f_27611_ # m20
public com.mojang.math.Matrix4f f_27612_ # m21
public com.mojang.math.Matrix4f f_27613_ # m22
public com.mojang.math.Matrix4f f_27614_ # m23
public com.mojang.math.Matrix4f f_27615_ # m30
public com.mojang.math.Matrix4f f_27616_ # m31
public com.mojang.math.Matrix4f f_27617_ # m32
public com.mojang.math.Matrix4f f_27618_ # m33
public com.mojang.math.Matrix3f f_8134_ # m00
public com.mojang.math.Matrix3f f_8135_ # m01
public com.mojang.math.Matrix3f f_8136_ # m02
public com.mojang.math.Matrix3f f_8137_ # m10
public com.mojang.math.Matrix3f f_8138_ # m11
public com.mojang.math.Matrix3f f_8139_ # m12
public com.mojang.math.Matrix3f f_8140_ # m20
public com.mojang.math.Matrix3f f_8141_ # m21
public com.mojang.math.Matrix3f f_8142_ # m22
public-f net.minecraft.world.inventory.Slot f_40220_ # x public-f net.minecraft.world.inventory.Slot f_40220_ # x
public-f net.minecraft.world.inventory.Slot f_40221_ # y public-f net.minecraft.world.inventory.Slot f_40221_ # y