More 1.19.3 porting

This commit is contained in:
DBotThePony 2023-01-07 13:28:06 +07:00
parent 1bb643d91b
commit bb52032364
Signed by: DBot
GPG Key ID: DCC23B5715498507
41 changed files with 134 additions and 111 deletions

View File

@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.android.feature
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Vector3f
import net.minecraft.ChatFormatting
import net.minecraft.client.Camera
import net.minecraft.client.renderer.LevelRenderer
@ -44,7 +43,10 @@ import ru.dbotthepony.mc.otm.core.component2
import ru.dbotthepony.mc.otm.core.component3
import ru.dbotthepony.mc.otm.core.formatPower
import ru.dbotthepony.mc.otm.core.genericPositions
import ru.dbotthepony.mc.otm.core.holder
import ru.dbotthepony.mc.otm.core.plus
import ru.dbotthepony.mc.otm.core.rotateXDegrees
import ru.dbotthepony.mc.otm.core.rotateYDegrees
import ru.dbotthepony.mc.otm.core.shortestDistanceBetween
import ru.dbotthepony.mc.otm.core.times
import ru.dbotthepony.mc.otm.milliTime
@ -301,7 +303,7 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
val event = ForgeEventFactory.onEnderTeleport(ply, blockPos.x + 0.5, blockPos.y.toDouble(), blockPos.z + 0.5)
if (event.isCanceled) {
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
(ply as ServerPlayer).connection.send(ClientboundSoundEntityPacket(SoundEvents.ITEM_BREAK.holder, SoundSource.PLAYERS, ply, 0.3f, 0.5f, ply.level.random.nextLong()))
return false
}
@ -333,8 +335,8 @@ class EnderTeleporterFeature(capability: MatteryPlayerCapability) : AndroidActiv
poseStack.pushPose()
poseStack.translate(x - vx, y - vy, z - vz)
poseStack.mulPose(Vector3f.YP.rotationDegrees(-camera.yRot))
poseStack.mulPose(Vector3f.XP.rotationDegrees(camera.xRot))
poseStack.rotateYDegrees(-camera.yRot)
poseStack.rotateXDegrees(camera.xRot)
val size = 1f + sin(milliTime / 250.0).toFloat() * 0.2f
val half = size / -2f

View File

@ -151,7 +151,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Synchro
blockPos.z + 0.5,
gravitationStrength.toFloat() * 60,
false,
Explosion.BlockInteraction.DESTROY
Level.ExplosionInteraction.BLOCK // TODO: 1.19.3
)
}
}

View File

@ -118,7 +118,7 @@ class ExplosionSphere(val hive: ExplosionSphereHive, var pos: Vec3, var stepVelo
val block = level.getBlockState(finalPos)
if (!block.isAir && block.block !is BlockExplosionDebugger) {
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(),false, Explosion.BlockInteraction.BREAK)
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY_WITH_DECAY)
val explosionResistance = block.getExplosionResistance(level, blockPos, explosion)
if (explosionResistance > force) {
@ -258,7 +258,7 @@ class ExplosionRay(val hive: ExplosionRayHive, var pos: Vec3, var stepVelocity:
val block = level.getBlockState(blockPos)
if (!block.isAir && block.block !is BlockExplosionDebugger) {
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(),false, Explosion.BlockInteraction.BREAK)
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY_WITH_DECAY)
val explosionResistance = block.getExplosionResistance(level, blockPos, explosion)
if (explosionResistance > force) {
@ -535,7 +535,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double,
z,
radius,
false,
Explosion.BlockInteraction.DESTROY
Level.ExplosionInteraction.BLOCK // TODO: 1.19.3
)
}

View File

@ -66,7 +66,7 @@ class AtlasSkinElement(
if (
_textureAtlasSprite == null ||
_textureAtlasSprite.name.let { it.namespace == "minecraft" && it.path == "missingno" } ||
_textureAtlasSprite.contents().name().let { it.namespace == "minecraft" && it.path == "missingno" } ||
changeset != WidgetAtlasHolder.INSTANCE.changeset
) {
val get = WidgetAtlasHolder.INSTANCE.getSprite(location)

View File

@ -3,13 +3,13 @@ package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.blaze3d.vertex.Tesselator
import com.mojang.blaze3d.vertex.VertexConsumer
import com.mojang.math.Matrix4f
import com.mojang.math.Vector3f
import net.minecraft.client.gui.Font
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.core.Vec3i
import net.minecraft.network.chat.Component
import net.minecraft.util.FormattedCharSequence
import org.joml.Matrix4f
import org.joml.Vector3f
import ru.dbotthepony.mc.otm.core.*
import kotlin.math.roundToInt
@ -21,12 +21,12 @@ fun VertexConsumer.color(color: RGBAColor): VertexConsumer = color(color.red, co
fun PoseStack.translate(vector: Vector) = translate(vector.x, vector.y, vector.z)
fun PoseStack.translate(vector: Vec3i) = translate(vector.x.toDouble(), vector.y.toDouble(), vector.z.toDouble())
fun PoseStack.translate(vector: Vector3f) = last().pose().multiplyWithTranslation(vector.x(), vector.y(), vector.z())
fun PoseStack.translate(vector: Vector3f) = translate(vector.x(), vector.y(), vector.z()) // TODO: 1.19.3
fun PoseStack.rotateAroundPoint(point: Vector, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
val last = last()
last.pose().rotateAroundPoint(point, axis, rotation, isDegrees)
last.normal().mul(axis.rotateAroundThis(rotation, isDegrees))
last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees))
}
fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) {
@ -38,7 +38,7 @@ fun PoseStack.rotateAroundPoint(point: Vector, rotation: IAngle) {
fun PoseStack.rotateAroundPoint(point: Vector3f, axis: Vector, rotation: Float, isDegrees: Boolean = false) {
val last = last()
last.pose().rotateAroundPoint(point, axis, rotation, isDegrees)
last.normal().mul(axis.rotateAroundThis(rotation, isDegrees))
last.normal().rotate(axis.rotateAroundThis(rotation, isDegrees))
}
fun PoseStack.rotateAroundPoint(point: Vector3f, rotation: IAngle) {

View File

@ -1,6 +1,5 @@
package ru.dbotthepony.mc.otm.client.render
import com.google.common.collect.ImmutableList
import com.mojang.blaze3d.pipeline.MainTarget
import com.mojang.blaze3d.platform.GlConst
import com.mojang.blaze3d.platform.GlStateManager
@ -8,34 +7,20 @@ import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.BufferBuilder
import com.mojang.blaze3d.vertex.BufferUploader
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.Tesselator
import com.mojang.blaze3d.vertex.VertexBuffer
import com.mojang.blaze3d.vertex.VertexFormat
import com.mojang.math.Matrix4f
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap
import it.unimi.dsi.fastutil.ints.Int2ObjectFunction
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.FogRenderer
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.core.Vec3i
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import net.minecraft.world.level.material.FogType
import org.lwjgl.opengl.GL14
import ru.dbotthepony.mc.otm.ClientConfig
import org.joml.Matrix4f
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.RGBAColor
import ru.dbotthepony.mc.otm.core.component1
import ru.dbotthepony.mc.otm.core.component2
import ru.dbotthepony.mc.otm.core.component3
import ru.dbotthepony.mc.otm.core.linearInterpolation
import ru.dbotthepony.mc.otm.milliTime
import java.lang.ref.WeakReference
import java.util.stream.Collectors
import kotlin.math.absoluteValue
import kotlin.math.ceil
import kotlin.math.pow
@Suppress("SameParameterValue")
object GlitchRenderer {
@ -215,7 +200,7 @@ object GlitchRenderer {
val glitchBuffer = glitchBuffer
val projection = RenderSystem.getProjectionMatrix()
RenderSystem.setProjectionMatrix(Matrix4f().also { it.setIdentity() })
RenderSystem.setProjectionMatrix(Matrix4f())
RenderSystem.getModelViewStack().also {
it.pushPose()

View File

@ -3,12 +3,12 @@ package ru.dbotthepony.mc.otm.client.render
import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.RenderStateShard
import net.minecraft.client.renderer.RenderStateShard.LineStateShard
import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.texture.TextureAtlasSprite
import org.joml.Matrix4f
import org.lwjgl.opengl.GL11.GL_ALWAYS
import org.lwjgl.opengl.GL11.GL_LESS
import ru.dbotthepony.mc.otm.client.minecraft
@ -22,7 +22,7 @@ import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sin
private val identity = Matrix4f().also { it.setIdentity() }
private val identity = Matrix4f()
var zLevel = 0f
var drawColor = RGBAColor(255, 255, 255, 255)
@ -513,11 +513,11 @@ fun TextureAtlasSprite.render(
stack: PoseStack,
x: Float = 0f,
y: Float = 0f,
width: Float = this.width.toFloat(),
height: Float = this.height.toFloat(),
width: Float,
height: Float,
winding: UVWindingOrder = UVWindingOrder.NORMAL
) {
RenderSystem.setShaderTexture(0, atlas().location())
RenderSystem.setShaderTexture(0, atlasLocation())
if (winding.isIdentity) {
drawTexturedRect(stack.last().pose(), x, y, width, height, u0, v0, u1, v1)

View File

@ -4,7 +4,6 @@ import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.BufferUploader
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.VertexFormat
import com.mojang.math.Vector3f
import net.minecraft.client.renderer.GameRenderer
import net.minecraftforge.client.event.RenderLevelStageEvent
import org.lwjgl.opengl.GL11.GL_LESS
@ -14,6 +13,7 @@ import ru.dbotthepony.mc.otm.core.component1
import ru.dbotthepony.mc.otm.core.component2
import ru.dbotthepony.mc.otm.core.component3
import ru.dbotthepony.mc.otm.core.linearInterpolation
import ru.dbotthepony.mc.otm.core.rotateX
import ru.dbotthepony.mc.otm.network.ShockwaveEffectPacket
import ru.dbotthepony.mc.otm.secondTimeD
import kotlin.math.PI
@ -52,7 +52,7 @@ object ShockwaveRenderer {
event.poseStack.pushPose()
val (x, y, z) = event.camera.position
event.poseStack.translate(pos.x - x, pos.y - y + 0.1f, pos.z - z) // render slightly above landed position
event.poseStack.mulPose(Vector3f.XP.rotation(PI.toFloat() / 2f))
event.poseStack.rotateX(PI.toFloat() / 2f)
uploadArc(event.poseStack.last.pose, builder, x = 0f, y = 0f, innerRadius = (radius - 1f).coerceAtLeast(0f), outerRadius = radius, triangleFan = false)
event.poseStack.popPose()

View File

@ -18,7 +18,7 @@ import kotlin.properties.Delegates
var isWidgetAtlasAvailable: Boolean = false
private set
class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, "gui") {
class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAtlasHolder(manager, LOCATION, INFO_LOCATION) {
var changeset = 0
private set
@ -75,6 +75,9 @@ class WidgetAtlasHolder private constructor(manager: TextureManager) : TextureAt
@JvmStatic
val LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/atlas/gui.png")
@JvmStatic
val INFO_LOCATION = ResourceLocation(OverdriveThatMatters.MOD_ID, "fuck/you/mojang")
@JvmStatic
var INSTANCE: WidgetAtlasHolder by WriteOnce()
private set

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
@ -16,6 +15,7 @@ import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.screen.widget.MatterGaugePanel
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.rotateY
import kotlin.math.PI
abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<T> {
@ -42,7 +42,7 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
val rotateFacing = facing == Direction.NORTH || facing == Direction.SOUTH
if (rotateFacing) {
stack.mulPose(Vector3f.YP.rotation(PI.toFloat() / 2f))
stack.rotateY(PI.toFloat() / 2f)
}
stack.scale(0.02f, 0.01f, 0.01f)
@ -64,7 +64,7 @@ abstract class BankRenderer<T : MatteryBlockEntity>(private val context: BlockEn
height = heightMax * gaugeLevel(blockEntity)
)
stack.mulPose(Vector3f.YP.rotation(PI.toFloat()))
stack.rotateY(PI.toFloat())
stack.translate(-50.0, 0.0, -101.0)
texture.uploadOntoPartialColor(

View File

@ -2,7 +2,6 @@ package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.*
import com.mojang.math.Matrix4f
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.client.renderer.MultiBufferSource
@ -10,6 +9,7 @@ import net.minecraft.client.renderer.blockentity.BeaconRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
import net.minecraft.world.phys.Vec3
import org.joml.Matrix4f
import org.lwjgl.opengl.GL30
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.block.entity.GravitationStabilizerBlockEntity

View File

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

View File

@ -1,37 +1,27 @@
package ru.dbotthepony.mc.otm.client.render.blockentity
import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.platform.GlStateManager.DestFactor
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Vector3f
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.block.model.ItemTransforms
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
import net.minecraft.client.server.IntegratedServer
import net.minecraft.core.particles.DustParticleOptions
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import org.lwjgl.opengl.GL14
import org.lwjgl.opengl.GL14.GL_ADD
import org.lwjgl.opengl.GL14.GL_FUNC_ADD
import org.lwjgl.opengl.GL14.GL_MIN
import org.joml.Vector3f
import org.lwjgl.opengl.GL14.glBlendColor
import ru.dbotthepony.mc.otm.NULLABLE_MINECRAFT_SERVER
import ru.dbotthepony.mc.otm.block.entity.WorkerState
import ru.dbotthepony.mc.otm.block.entity.matter.MatterReplicatorBlockEntity
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.lockBlendFunc
import ru.dbotthepony.mc.otm.client.render.popScissorRect
import ru.dbotthepony.mc.otm.client.render.pushScissorRect
import ru.dbotthepony.mc.otm.client.screen.widget.PowerGaugePanel
import ru.dbotthepony.mc.otm.core.component1
import ru.dbotthepony.mc.otm.core.component2
import ru.dbotthepony.mc.otm.core.component3
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.normalizeAngleDeg
import ru.dbotthepony.mc.otm.core.rotateYDegrees
import ru.dbotthepony.mc.otm.isPaused
class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.Context) : BlockEntityRenderer<MatterReplicatorBlockEntity> {
@ -78,7 +68,7 @@ class MatterReplicatorRenderer(private val context: BlockEntityRendererProvider.
if (!isPaused)
tile.renderRotation = normalizeAngleDeg(tile.renderRotation + diff / 10_000_000f)
pose.mulPose(Vector3f.YP.rotationDegrees(tile.renderRotation))
pose.rotateYDegrees(tile.renderRotation)
val model = context.itemRenderer.getModel(
item,

View File

@ -1,13 +1,14 @@
package ru.dbotthepony.mc.otm.client.screen.panels
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.client.gui.components.Widget
import net.minecraft.client.gui.components.Renderable
import net.minecraft.client.gui.components.events.GuiEventListener
import net.minecraft.client.gui.screens.Screen
// before 1.19.3 Renderable was Widget
class Panel2Widget<out S: Screen, out P : EditablePanel<S>>(
val panel: P
) : GuiEventListener, Widget {
) : GuiEventListener, Renderable {
init {
require(panel.parent == null) { "Widget wrapped panels can't have a parent ($panel has parent ${panel.parent})" }
}

View File

@ -104,7 +104,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
if (icon != null) {
val texture = minecraft.getTextureAtlas(icon.first).apply(icon.second)
RenderSystem.setShaderTexture(0, texture.atlas().location())
RenderSystem.setShaderTexture(0, texture.atlasLocation())
GuiComponent.blit(stack, 1, 1, 0, 16, 16, texture)
} else {
noItemIcon?.render(stack, width = width, height = height)

View File

@ -1,5 +1,6 @@
package ru.dbotthepony.mc.otm.core
import com.mojang.blaze3d.vertex.PoseStack
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
@ -541,3 +542,35 @@ fun angleDifferenceDeg(angle1: Float, angle2: Float): Float {
return 360f - diff
}
// 1.19.3 stuff
fun PoseStack.rotateY(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 1f, 0f)))
return this
}
fun PoseStack.rotateX(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 1f, 0f, 0f)))
return this
}
fun PoseStack.rotateZ(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(rotation, 0f, 0f, 1f)))
return this
}
fun PoseStack.rotateYDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 1f, 0f)))
return this
}
fun PoseStack.rotateXDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 1f, 0f, 0f)))
return this
}
fun PoseStack.rotateZDegrees(rotation: Float): PoseStack {
mulPose(Quaternionf(AxisAngle4f(toRadians(rotation), 0f, 0f, 1f)))
return this
}

View File

@ -5,6 +5,7 @@ import net.minecraft.network.chat.MutableComponent
import net.minecraft.network.chat.contents.LiteralContents
import net.minecraft.network.chat.contents.TranslatableContents
import net.minecraft.resources.ResourceLocation
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.item.Item
import net.minecraft.world.level.block.Block
import net.minecraftforge.registries.ForgeRegistries
@ -28,3 +29,6 @@ val Item.registryName get() = ForgeRegistries.ITEMS.getKeyNullable(this)
val Block.registryName get() = ForgeRegistries.BLOCKS.getKeyNullable(this)
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

@ -113,6 +113,6 @@ abstract class AbstractExoPackSlotUpgradeItem(properties: Properties = defaultPr
override fun getUseAnimation(p_41452_: ItemStack): UseAnim = UseAnim.BOW
companion object {
fun defaultProperties(rarity: Rarity = Rarity.UNCOMMON) = Properties().stacksTo(8).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).fireResistant()
fun defaultProperties(rarity: Rarity = Rarity.UNCOMMON): Properties = Properties().stacksTo(8).rarity(Rarity.UNCOMMON).fireResistant()
}
}

View File

@ -71,7 +71,7 @@ open class BatteryItem : Item {
receive: Decimal,
extract: Decimal = receive,
initialBatteryLevel: Decimal = Decimal.ZERO
) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
) : super(Properties().stacksTo(1)) {
isCreative = false
this._capacity = { storage }
this._receive = { receive }
@ -84,7 +84,7 @@ open class BatteryItem : Item {
receive: () -> Decimal,
extract: () -> Decimal = receive,
initialBatteryLevel: () -> Decimal = { Decimal.ZERO }
) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
) : super(Properties().stacksTo(1)) {
isCreative = false
this._capacity = storage
this._receive = receive
@ -92,7 +92,7 @@ open class BatteryItem : Item {
this._initialBatteryLevel = initialBatteryLevel
}
constructor(values: BatteryBalanceValues) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(values: BatteryBalanceValues) : super(Properties().stacksTo(1)) {
isCreative = false
this._capacity = values::capacity
this._receive = values::receive
@ -100,7 +100,7 @@ open class BatteryItem : Item {
this._initialBatteryLevel = values::initialBatteryLevel
}
constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
isCreative = true
_capacity = { Decimal.LONG_MAX_VALUE }
_receive = { Decimal.LONG_MAX_VALUE }

View File

@ -26,7 +26,7 @@ import ru.dbotthepony.mc.otm.matter.MatterManager
import java.util.*
import java.util.stream.Stream
class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) {
class CreativePatternItem : Item(Properties().rarity(Rarity.EPIC).stacksTo(1)) {
private object Patterns : IPatternStorage, ICapabilityProvider {
private val resolver = LazyOptional.of<IPatternStorage> { this }

View File

@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.runIfClient
class ExoPackCraftingUpgradeItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.RARE)) {
class ExoPackCraftingUpgradeItem : Item(Properties().stacksTo(1).rarity(Rarity.RARE)) {
override fun getUseDuration(p_41454_: ItemStack): Int {
return 30
}

View File

@ -17,7 +17,7 @@ import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.registry.MRegistry
import ru.dbotthepony.mc.otm.runIfClient
class ExoPackProbeItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.EPIC)) {
class ExoPackProbeItem : Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
override fun getUseDuration(p_41454_: ItemStack): Int {
return 30
}

View File

@ -11,7 +11,7 @@ import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.core.TranslatableComponent
class GravitationalDisruptorItem :
Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1).rarity(Rarity.EPIC)) {
Item(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
override fun appendHoverText(
p_41421_: ItemStack,
p_41422_: Level?,

View File

@ -94,17 +94,17 @@ class MatterCapacitorItem : Item {
private val isCreative: Boolean
constructor(storage: Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(storage: Decimal) : super(Properties().stacksTo(1)) {
isCreative = false
_capacity = { storage }
}
constructor(storage: () -> Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(storage: () -> Decimal) : super(Properties().stacksTo(1)) {
isCreative = false
_capacity = storage
}
constructor() : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).rarity(Rarity.EPIC)) {
constructor() : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
isCreative = true
_capacity = { Decimal.LONG_MAX_VALUE }
}

View File

@ -15,7 +15,7 @@ import ru.dbotthepony.mc.otm.core.set
import ru.dbotthepony.mc.otm.matter.IMatterValue
import ru.dbotthepony.mc.otm.matter.MatterValue
class MatterDustItem : Item(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(64)), IMatterItem {
class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem {
private fun matter(stack: ItemStack): Decimal {
return stack.tag?.get("matter")?.let { return@let Decimal.deserializeNBT(it) } ?: return Decimal.ZERO
}

View File

@ -21,7 +21,7 @@ import ru.dbotthepony.mc.otm.entity.MinecartCargoCrate
import ru.dbotthepony.mc.otm.registry.MEntityTypes
import kotlin.math.floor
class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16).tab(if (color == null) OverdriveThatMatters.INSTANCE.CREATIVE_TAB else OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE)) {
class MinecartCargoCrateItem(val color: DyeColor?) : Item(Properties().stacksTo(16)) {
init {
DispenserBlock.registerBehavior(this, Companion)
}

View File

@ -27,17 +27,17 @@ class PatternStorageItem : Item {
val capacity get() = _capacity.invoke()
var isCreative: Boolean
constructor(capacity: Int) : super(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) {
constructor(capacity: Int) : super(Properties().stacksTo(1)) {
_capacity = { capacity }
isCreative = false
}
constructor(capacity: () -> Int) : super(Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) {
constructor(capacity: () -> Int) : super(Properties().stacksTo(1)) {
_capacity = capacity
isCreative = false
}
constructor() : super(Properties().rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB).stacksTo(1)) {
constructor() : super(Properties().rarity(Rarity.EPIC).stacksTo(1)) {
isCreative = true
_capacity = { Int.MAX_VALUE }
}

View File

@ -20,7 +20,7 @@ enum class PillType {
BECOME_ANDROID, BECOME_HUMANE, OBLIVION
}
class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(p_41454_: ItemStack): Int {
return 24
}
@ -65,7 +65,7 @@ class HealPillItem : Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab(
}
class PillItem(val pillType: PillType) :
Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
Item(Properties().stacksTo(64).rarity(Rarity.UNCOMMON)) {
override fun getUseDuration(p_41454_: ItemStack): Int {
return 32

View File

@ -29,7 +29,7 @@ import java.math.BigInteger
import java.util.*
class PortableCondensationDriveItem(capacity: Int) :
Item(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
Item(Properties().stacksTo(1)) {
val capacity: BigInteger = capacity.toBigInteger()
private inner class DriveCapability(private val stack: ItemStack) : ICapabilityProvider {

View File

@ -41,7 +41,7 @@ private object GravitationStabilizerArmorRenderProperties : IClientItemExtension
}
}
class ItemPortableGravitationStabilizer : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
class ItemPortableGravitationStabilizer : ArmorItem(GravitationStabilizerArmorMaterial, EquipmentSlot.CHEST, Properties().stacksTo(1).rarity(Rarity.RARE)) {
override fun initializeClient(consumer: Consumer<IClientItemExtensions>) {
super.initializeClient(consumer)
consumer.accept(GravitationStabilizerArmorRenderProperties)

View File

@ -292,21 +292,21 @@ class QuantumBatteryItem : Item {
Int2ObjectOpenHashMap()
}
constructor(saveDataID: String) : super(Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(saveDataID: String) : super(Properties().stacksTo(1).rarity(Rarity.EPIC)) {
isCreative = true
_capacity = { null }
_throughput = { null }
this.saveDataID = "otm_$saveDataID".intern()
}
constructor(saveDataID: String, capacity: Decimal, io: Decimal) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(saveDataID: String, capacity: Decimal, io: Decimal) : super(Properties().stacksTo(1)) {
isCreative = false
_capacity = { capacity }
_throughput = { io }
this.saveDataID = "otm_$saveDataID".intern()
}
constructor(saveDataID: String, values: ConciseBalanceValues) : super(Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
constructor(saveDataID: String, values: ConciseBalanceValues) : super(Properties().stacksTo(1)) {
isCreative = false
_capacity = values::capacity
_throughput = values::throughput

View File

@ -18,10 +18,10 @@ import ru.dbotthepony.mc.otm.core.*
open class SingleUseBatteryItem(
private val _capacity: () -> Decimal,
private val _throughput: () -> Decimal? = { null },
properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)
properties: Properties = Properties().stacksTo(1)
) : Item(properties) {
constructor(values: ConciseBalanceValues, properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) : this(values::capacity, values::throughput, properties)
constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) : this({ storage }, { throughput }, properties)
constructor(values: ConciseBalanceValues, properties: Properties = Properties().stacksTo(1)) : this(values::capacity, values::throughput, properties)
constructor(storage: Decimal, throughput: Decimal? = null, properties: Properties = Properties().stacksTo(1)) : this({ storage }, { throughput }, properties)
val capacity get() = _capacity.invoke()
val throughput get() = _throughput.invoke()
@ -58,7 +58,7 @@ open class SingleUseBatteryItem(
}
}
class ZPMItem : SingleUseBatteryItem(ServerConfig.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC).tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB)) {
class ZPMItem : SingleUseBatteryItem(ServerConfig.ZPM_BATTERY, Properties().stacksTo(1).rarity(Rarity.EPIC)) {
override fun appendHoverText(
itemStack: ItemStack,
p_41422_: Level?,

View File

@ -414,9 +414,9 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, pr
yaw += (rotFire.yaw + (predictedData?.fireAnimDeviation?.yaw ?: 0.0)) * fireAnim * (1.0 - progress * 0.6)
roll += (rotFire.roll + (predictedData?.fireAnimDeviation?.roll ?: 0.0)) * fireAnim * (1.0 - progress * 0.6)
pose.mulPose(Vector3f.ZP.rotation(roll.toFloat()))
pose.mulPose(Vector3f.YP.rotation(yaw.toFloat()))
pose.mulPose(Vector3f.XP.rotation(pitch.toFloat()))
pose.rotateZ(roll.toFloat())
pose.rotateY(yaw.toFloat())
pose.rotateX(pitch.toFloat())
itemInHandRenderer.renderItem(
player,
@ -436,8 +436,8 @@ abstract class AbstractWeaponItem<D : WeaponDataTable>(val tables: KClass<D>, pr
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
pose.translate(-0.85, 0.25, -0.25)
pose.mulPose(Vector3f.ZP.rotationDegrees(180f))
pose.mulPose(Vector3f.YP.rotationDegrees(180f))
pose.rotateZ(PI.toFloat())
pose.rotateY(PI.toFloat())
pose.scale(0.01f, 0.01f, 0.01f)
setDrawColor(holoHudBackground)

View File

@ -6,6 +6,8 @@ import net.minecraft.network.FriendlyByteBuf
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.inventory.CraftingContainer
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.crafting.CookingBookCategory
import net.minecraft.world.item.crafting.CraftingBookCategory
import net.minecraft.world.item.crafting.CraftingRecipe
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.item.crafting.RecipeSerializer
@ -21,12 +23,13 @@ import ru.dbotthepony.mc.otm.core.tagNotNull
class EnergyContainerRecipe(
p_44153_: ResourceLocation,
p_44154_: String,
category: CraftingBookCategory,
p_44155_: Int,
p_44156_: Int,
p_44157_: NonNullList<Ingredient>,
p_44158_: ItemStack,
) : ShapedRecipe(p_44153_, p_44154_, p_44155_, p_44156_, p_44157_, p_44158_) {
constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.width, parent.height, parent.ingredients, parent.resultItem)
) : ShapedRecipe(p_44153_, p_44154_, category, p_44155_, p_44156_, p_44157_, p_44158_) {
constructor(parent: ShapedRecipe) : this(parent.id, parent.group, parent.category(), parent.width, parent.height, parent.ingredients, parent.resultItem)
override fun assemble(container: CraftingContainer): ItemStack {
val itemStack = super.assemble(container)

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.registry
import net.minecraft.ChatFormatting
import net.minecraft.core.BlockPos
import net.minecraft.network.chat.Component
import net.minecraft.sounds.SoundEvents
import net.minecraft.util.valueproviders.UniformInt
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.monster.Zombie
@ -133,7 +134,7 @@ object MBlocks {
val METAL_BEAM: Block by registry.register(MNames.METAL_BEAM) { Block(BlockBehaviour.Properties.of(Material.METAL, DyeColor.GRAY).explosionResistance(14f).destroyTime(2.5f).requiresCorrectToolForDrops()) }
val TRITANIUM_DOOR = registry.allColored(MNames.TRITANIUM_DOOR) { color, _ ->
object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
object : DoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) {
override fun appendHoverText(
p_49816_: ItemStack,
p_49817_: BlockGetter?,
@ -161,7 +162,7 @@ object MBlocks {
}
val TRITANIUM_TRAPDOOR = registry.allColored(MNames.TRITANIUM_TRAPDOOR) { color, _ ->
object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops()) {
object : TrapDoorBlock(Properties.of(Material.METAL, color ?: DyeColor.LIGHT_BLUE).explosionResistance(80f).noOcclusion().destroyTime(3f).requiresCorrectToolForDrops(), SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN) {
override fun appendHoverText(
p_49816_: ItemStack,
p_49817_: BlockGetter?,

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.Registry
import net.minecraft.core.registries.Registries
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister
@ -8,7 +9,7 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction
object MItemFunctionTypes {
private val registry = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, OverdriveThatMatters.MOD_ID)
private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID)
val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) }

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.Registry
import net.minecraft.core.registries.Registries
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister
@ -13,7 +14,7 @@ import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly
import ru.dbotthepony.mc.otm.data.condition.ChanceCondition
object MLootItemConditions {
private val registry = DeferredRegister.create(Registry.LOOT_ITEM_REGISTRY, OverdriveThatMatters.MOD_ID)
private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID)
val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(HasExoPackCondition) }
val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(ChanceWithPlaytimeCondition) }

View File

@ -13,7 +13,8 @@ import ru.dbotthepony.mc.otm.OverdriveThatMatters
object MSoundEvents {
private val registry: DeferredRegister<SoundEvent> = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, OverdriveThatMatters.MOD_ID)
private fun make(name: String) = registry.register(name) { SoundEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) }
// TODO: 1.19.3
private fun make(name: String) = registry.register(name) { SoundEvent.createVariableRangeEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) }
val RIFLE_SHOT: SoundEvent by make("item.rifle_shot")
val PLASMA_WEAPON_OVERHEAT: SoundEvent by make("item.plasma_weapon_overheat")

View File

@ -1,9 +1,9 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.stats.StatFormatter
import net.minecraft.stats.Stats
import net.minecraftforge.eventbus.api.SubscribeEvent
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
import ru.dbotthepony.mc.otm.registry.StatNames.DAMAGE_ABSORBED
import ru.dbotthepony.mc.otm.registry.StatNames.HEALTH_REGENERATED
@ -12,9 +12,9 @@ import ru.dbotthepony.mc.otm.registry.StatNames.POWER_CONSUMED
object MStats {
fun registerVanilla(event: FMLCommonSetupEvent) {
event.enqueueWork {
Registry.register(Registry.CUSTOM_STAT, DAMAGE_ABSORBED, DAMAGE_ABSORBED)
Registry.register(Registry.CUSTOM_STAT, HEALTH_REGENERATED, HEALTH_REGENERATED)
Registry.register(Registry.CUSTOM_STAT, POWER_CONSUMED, POWER_CONSUMED)
Registry.register(BuiltInRegistries.CUSTOM_STAT, DAMAGE_ABSORBED, DAMAGE_ABSORBED)
Registry.register(BuiltInRegistries.CUSTOM_STAT, HEALTH_REGENERATED, HEALTH_REGENERATED)
Registry.register(BuiltInRegistries.CUSTOM_STAT, POWER_CONSUMED, POWER_CONSUMED)
Stats.CUSTOM[DAMAGE_ABSORBED, StatFormatter.DIVIDE_BY_TEN]
Stats.CUSTOM[HEALTH_REGENERATED, StatFormatter.DIVIDE_BY_TEN]
Stats.CUSTOM[POWER_CONSUMED, StatFormatter.DIVIDE_BY_TEN]

View File

@ -18,7 +18,7 @@ class StripedColoredDecorativeBlock(
val basename: String,
val blockFactory: (colorA: DyeColor, colorB: DyeColor) -> Block,
val itemFactory: ((colorA: DyeColor, colorB: DyeColor, block: Block) -> Item) = { _, _, block ->
BlockItem(block, Item.Properties().tab(OverdriveThatMatters.INSTANCE.CREATIVE_TAB_DECORATIVE).stacksTo(64))
BlockItem(block, Item.Properties().stacksTo(64))
}
) {
private val mapBlocks = EnumMap<DyeColor, EnumMap<DyeColor, RegistryObject<Block>>>(DyeColor::class.java)

View File

@ -1,8 +1,6 @@
package ru.dbotthepony.mc.otm.worldgen
import net.minecraft.core.Holder
import net.minecraft.data.BuiltinRegistries.CONFIGURED_FEATURE
import net.minecraft.data.BuiltinRegistries.PLACED_FEATURE
import net.minecraft.data.worldgen.features.OreFeatures
import net.minecraft.world.level.levelgen.VerticalAnchor
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature