Some backporting

This commit is contained in:
DBotThePony 2024-01-01 23:45:19 +07:00
parent d24a72d435
commit 3fc9435259
Signed by: DBot
GPG Key ID: DCC23B5715498507
59 changed files with 98 additions and 87 deletions

View File

@ -53,7 +53,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
check(experience >= 0.0) { "Invalid experience amount to store: $experience" }
this.experience += experience
for (dir in Direction.entries) {
for (dir in Direction.values()) {
val tile = pointOfReference.level?.getBlockEntity(pointOfReference.blockPos + dir)
if (tile is EssenceStorageBlockEntity) {
@ -75,7 +75,7 @@ class ExperienceStorage(val maxExperience: DoubleSupplier = DoubleSupplier { Dou
fun tryTransferExperience(pointOfReference: BlockEntity) {
if (experience >= 1.0) {
for (dir in Direction.entries) {
for (dir in Direction.values()) {
val tile = pointOfReference.level?.getBlockEntity(pointOfReference.blockPos + dir)
if (tile is EssenceStorageBlockEntity) {

View File

@ -763,7 +763,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
}
init {
for (dir in Direction.entries) {
for (dir in Direction.values()) {
vec2Dir[vecKey(dir.normal)] = dir
}
}

View File

@ -11,6 +11,7 @@ import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.item.ItemEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.level.Explosion
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
@ -124,7 +125,7 @@ class BlackHoleBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : Mattery
blockPos.z + 0.5,
gravitationStrength.toFloat() * 60,
false,
Level.ExplosionInteraction.BLOCK // TODO: 1.19.3
Explosion.BlockInteraction.DESTROY // TODO: 1.19.3
)
}
}

View File

@ -126,7 +126,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.DESTROY_WITH_DECAY)
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY)
val explosionResistance = block.getExplosionResistance(level, blockPos, explosion)
if (explosionResistance > force) {
@ -266,7 +266,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.DESTROY_WITH_DECAY)
val explosion = Explosion(level, null, null, null, pos.x, pos.y, pos.z, force.toFloat(), false, Explosion.BlockInteraction.DESTROY)
val explosionResistance = block.getExplosionResistance(level, blockPos, explosion)
if (explosionResistance > force) {
@ -543,7 +543,7 @@ private data class QueuedExplosion(val x: Double, val y: Double, val z: Double,
z,
radius,
false,
Level.ExplosionInteraction.BLOCK // TODO: 1.19.3
Explosion.BlockInteraction.DESTROY // TODO: 1.19.3
)
}

View File

@ -9,6 +9,7 @@ import net.minecraftforge.items.IItemHandler
import net.minecraftforge.registries.ForgeRegistries
import net.minecraftforge.registries.IdMappingEvent
import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.getID
import ru.dbotthepony.mc.otm.registry.MBlockEntities

View File

@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.config.ItemsConfig
import ru.dbotthepony.mc.otm.container.HandlerFilter
import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.container.get
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.orNull
import ru.dbotthepony.mc.otm.core.util.FluidStackValueCodec

View File

@ -122,7 +122,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe
}
}
val dye = DyeColor.entries.firstOrNull { stack.`is`(it.tag) } ?: return false
val dye = DyeColor.values().firstOrNull { stack.`is`(it.tag) } ?: return false
return dyeStored(dye) + HUE_PER_ITEM <= MAX_STORAGE
}
@ -130,7 +130,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe
if (!stack.equals(existing, false))
return super.modifyInsertCount(slot, stack, existing, simulate)
val dye = DyeColor.entries.firstOrNull { stack.`is`(it.tag) } ?: return 0
val dye = DyeColor.values().firstOrNull { stack.`is`(it.tag) } ?: return 0
return stack.count.coerceAtMost((MAX_STORAGE - dyeStored(dye)) / HUE_PER_ITEM - existing.count)
}
@ -167,7 +167,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe
if (k == "water")
dyeStored[null] = it.getInt("water")
else
dyeStored[DyeColor.entries.firstOrNull { it.getName() == k } ?: continue] = it.getInt(k)
dyeStored[DyeColor.values().firstOrNull { it.getName() == k } ?: continue] = it.getInt(k)
}
}
}
@ -187,7 +187,7 @@ class PainterBlockEntity(blockPos: BlockPos, blockState: BlockState) : MatteryDe
}
}
val dye = DyeColor.entries.firstOrNull { slot.item.`is`(it.tag) } ?: continue
val dye = DyeColor.values().firstOrNull { slot.item.`is`(it.tag) } ?: continue
val stored = dyeStored(dye)
if (stored + HUE_PER_ITEM <= MAX_STORAGE) {

View File

@ -46,6 +46,7 @@ import ru.dbotthepony.mc.otm.container.set
import ru.dbotthepony.mc.otm.container.util.slotIterator
import ru.dbotthepony.mc.otm.core.collect.map
import ru.dbotthepony.mc.otm.core.collect.toList
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.util.ItemStorageStackSorter
import ru.dbotthepony.mc.otm.core.value

View File

@ -15,6 +15,7 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
import ru.dbotthepony.mc.otm.config.MachinesConfig
import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.container.HandlerFilter
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.menu.tech.ChemicalGeneratorMenu
import ru.dbotthepony.mc.otm.registry.MBlockEntities
import ru.dbotthepony.mc.otm.core.math.Decimal

View File

@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer
import ru.dbotthepony.mc.otm.container.balance
import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.maybe
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.value
import ru.dbotthepony.mc.otm.menu.tech.PlatePressMenu
import ru.dbotthepony.mc.otm.menu.tech.TwinPlatePressMenu

View File

@ -31,6 +31,7 @@ import ru.dbotthepony.mc.otm.container.UpgradeContainer
import ru.dbotthepony.mc.otm.container.balance
import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.maybe
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.immutableList
import ru.dbotthepony.mc.otm.core.value
import ru.dbotthepony.mc.otm.menu.tech.PoweredFurnaceMenu

View File

@ -3,6 +3,8 @@ 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.core.Vec3i
import org.joml.Matrix4f
import org.joml.Quaternionf
@ -25,6 +27,8 @@ fun VertexConsumer.color(color: RGBAColor?): VertexConsumer {
return this
}
fun PoseStack.translate(x: Float, y: Float, z: Float) = translate(x.toDouble(), y.toDouble(), z.toDouble())
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) = translate(vector.x(), vector.y(), vector.z())

View File

@ -9,6 +9,7 @@ import ru.dbotthepony.mc.otm.client.font
import ru.dbotthepony.mc.otm.client.render.DynamicBufferSource
import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.draw
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.core.get
import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom
import ru.dbotthepony.mc.otm.core.math.RGBAColor

View File

@ -22,6 +22,7 @@ import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.DeviceControls
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel

View File

@ -74,7 +74,7 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
it.dockTop = 4f
}
EditablePanel(this, frame, width = 6f * (DyeColor.entries.size / 2f + 1f)).also {
EditablePanel(this, frame, width = 6f * (DyeColor.values().size / 2f + 1f)).also {
it.dock = Dock.RIGHT
it.dockLeft = 4f
@ -83,16 +83,16 @@ class PainterScreen(menu: PainterMenu, inventory: Inventory, title: Component) :
EditablePanel(this, it, height = 46f).also {
it.dock = Dock.TOP
for (i in 0 until DyeColor.entries.size / 2) {
Bar(it, DyeColor.entries[i])
for (i in 0 until DyeColor.values().size / 2) {
Bar(it, DyeColor.values()[i])
}
}
EditablePanel(this, it, height = 46f).also {
it.dock = Dock.BOTTOM
for (i in DyeColor.entries.size / 2 until DyeColor.entries.size) {
Bar(it, DyeColor.entries[i])
for (i in DyeColor.values().size / 2 until DyeColor.values().size) {
Bar(it, DyeColor.values()[i])
}
}
}

View File

@ -56,7 +56,7 @@ class MatterPanelScreen(
val controls = DeviceControls(this, frame)
controls.sortingButtons(menu.settings::isAscending.asGetterSetter(), menu.settings::sorting.asGetterSetter(), ItemSorter.DEFAULT) {
for (v in ItemSorter.entries) {
for (v in ItemSorter.values()) {
add(v, skinElement = v.icon, tooltip = v.title)
}
}

View File

@ -898,6 +898,7 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
}
}
@OptIn(ExperimentalStdlibApi::class)
fun tickHover(mouseX: Float, mouseY: Float): Boolean {
if (isRemoved)
return false

View File

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

View File

@ -440,7 +440,7 @@ class DeviceControls<out S : MatteryScreen<*>>(
private fun makeButtons() {
buttons = sortingButtons(input.settings::isAscending.asGetterSetter(), input.settings::sorting.asGetterSetter(), ItemStackSorter.DEFAULT) {
for (v in ItemStackSorter.entries) {
for (v in ItemStackSorter.values()) {
add(v, v.icon, v.title)
}

View File

@ -100,7 +100,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.atlasLocation())
RenderSystem.setShaderTexture(0, texture.atlas().location())
graphics.renderSprite(texture, 1f, 1f, 16f, 16f)
} else {
slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height)

View File

@ -36,7 +36,7 @@ class DriveViewerScreen(menu: DriveViewerMenu, inventory: Inventory, title: Comp
val controls = DeviceControls(this, frame, redstoneConfig = menu.redstoneConfig, energyConfig = menu.energyConfig)
controls.sortingButtons(menu.settings::isAscending.asGetterSetter(), menu.settings::sorting.asGetterSetter(), ItemStorageStackSorter.DEFAULT) {
for (v in ItemStorageStackSorter.entries) {
for (v in ItemStorageStackSorter.values()) {
add(v, v.icon, v.title)
}
}

View File

@ -53,7 +53,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
val controls = DeviceControls(this, frame)
controls.sortingButtons(menu.settings::ascendingSort.asGetterSetter(), menu.settings::sorting.asGetterSetter(), ItemStorageStackSorter.DEFAULT) {
for (v in ItemStorageStackSorter.entries) {
for (v in ItemStorageStackSorter.values()) {
add(v, skinElement = v.icon, tooltip = v.title)
}
}
@ -88,7 +88,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
.also {
it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.refill_source.desc"))
for (setting in ItemMonitorPlayerSettings.IngredientPriority.entries) {
for (setting in ItemMonitorPlayerSettings.IngredientPriority.values()) {
it.add(setting, setting.icon, setting.component, setting.winding)
}
@ -109,7 +109,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
.also {
it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.result_target.desc"))
for (setting in ItemMonitorPlayerSettings.ResultTarget.entries) {
for (setting in ItemMonitorPlayerSettings.ResultTarget.values()) {
it.add(setting, setting.icon, setting.component, setting.winding)
}
}
@ -121,7 +121,7 @@ class ItemMonitorScreen(menu: ItemMonitorMenu, inventory: Inventory, title: Comp
.also {
it.tooltips.add(TranslatableComponent("otm.gui.item_monitor.amount.desc"))
for (setting in ItemMonitorPlayerSettings.Amount.entries) {
for (setting in ItemMonitorPlayerSettings.Amount.values()) {
it.add(setting, setting.icon, setting.component, setting.winding)
}
}

View File

@ -20,6 +20,7 @@ import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.playGuiClickSound
import ru.dbotthepony.mc.otm.client.render.RenderGravity
import ru.dbotthepony.mc.otm.client.render.Widgets18
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.client.screen.MatteryScreen
import ru.dbotthepony.mc.otm.client.screen.panels.*
import ru.dbotthepony.mc.otm.client.screen.panels.button.ButtonPanel

View File

@ -87,7 +87,7 @@ open class FluidGaugePanel<out S : Screen>(
RenderSystem.depthFunc(GL11.GL_ALWAYS)
RenderSystem.setShaderColor(tint.red, tint.green, tint.blue, tint.alpha)
RenderSystem.setShaderTexture(0, sprite.atlasLocation())
RenderSystem.setShaderTexture(0, sprite.atlas().location())
tesselator.end()

View File

@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.client.render.WidgetLocation
import ru.dbotthepony.mc.otm.client.render.tesselator
import ru.dbotthepony.mc.otm.client.render.translate
import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel
import ru.dbotthepony.mc.otm.core.TextComponent
import ru.dbotthepony.mc.otm.core.TranslatableComponent

View File

@ -19,6 +19,7 @@ import ru.dbotthepony.mc.otm.client.render.MGUIGraphics
import ru.dbotthepony.mc.otm.client.render.ItemStackIcon
import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel
import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.recipe.PainterRecipe
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MNames

View File

@ -1,12 +1,11 @@
package ru.dbotthepony.mc.otm.compat.vanilla
import net.minecraft.client.gui.screens.MenuScreens
import net.minecraft.core.registries.Registries
import net.minecraft.core.Registry
import net.minecraft.world.Container
import net.minecraft.world.SimpleContainer
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player
import net.minecraft.world.flag.FeatureFlags
import net.minecraft.world.inventory.MenuType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
@ -42,7 +41,7 @@ class MatteryChestMenu(
}
companion object {
private val registrar = DeferredRegister.create(Registries.MENU, OverdriveThatMatters.MOD_ID)
private val registrar = DeferredRegister.create(Registry.MENU_REGISTRY, OverdriveThatMatters.MOD_ID)
private val GENERIC_9x1 by registrar.register("generic_9x1") { MenuType(::c9x1) }
private val GENERIC_9x2 by registrar.register("generic_9x2") { MenuType(::c9x2) }

View File

@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.container
import net.minecraft.world.item.ItemStack
import net.minecraftforge.items.IItemHandler
import ru.dbotthepony.mc.otm.core.copyWithCount
class ContainerHandler(
private val container: IMatteryContainer,

View File

@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.container.util.slotIterator
import ru.dbotthepony.mc.otm.core.addAll
import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.collect.toList
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.map
import ru.dbotthepony.mc.otm.core.util.ItemStackSorter

View File

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.container
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap
import net.minecraft.world.Container
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.core.copyWithCount
class ShadowContainer(private val parent: Container) : IContainer by IContainer.wrap(parent) {
private val shadowed = Int2ObjectArrayMap<ItemStack>(0)

View File

@ -475,3 +475,9 @@ fun <A, B> lazy2(a: () -> A, b: A.() -> B): Supplier<B> {
}
inline val <R : Recipe<T>, T : Container> R.value get() = this
fun ItemStack.copyWithCount(count: Int): ItemStack {
val copy = copy()
copy.count = count
return copy
}

View File

@ -97,6 +97,10 @@ sealed class Decimal : Number(), Comparable<Decimal> {
abstract operator fun div(other: BigInteger): Decimal
// /Primitive operators
override fun toChar(): Char {
return toInt().toChar()
}
// "de-virtualize" generic method
abstract override fun compareTo(other: Decimal): Int
@ -1319,7 +1323,7 @@ sealed class Decimal : Number(), Comparable<Decimal> {
}
override fun minus(other: BigInteger): Decimal {
return valueOf(-other)
return valueOf(other.negate())
}
override fun times(other: BigInteger): Decimal {

View File

@ -207,6 +207,6 @@ fun OutputStream.writeBinaryJson(element: JsonElement) {
*/
fun InputStream.readBinaryJson(): JsonElement {
val id = read() - 1
val reader = BinaryElementType.entries.getOrNull(id) ?: throw JsonParseException("Unknown element type ${id + 1}")
val reader = BinaryElementType.values().getOrNull(id) ?: throw JsonParseException("Unknown element type ${id + 1}")
return reader.read(this)
}

View File

@ -259,7 +259,7 @@ fun OutputStream.writeVarIntLE(value: Int) {
}
fun InputStream.readVarLongLE(sizeLimit: NbtAccounter? = null): Long {
sizeLimit?.accountBytes(1L)
sizeLimit?.accountBits(8L)
val readFirst = read()
@ -278,7 +278,7 @@ fun InputStream.readVarLongLE(sizeLimit: NbtAccounter? = null): Long {
while (nextBit != 0) {
result = result or (read shl i).toLong()
sizeLimit?.accountBytes(1L)
sizeLimit?.accountBits(8L)
read = read()
if (read < 0) {

View File

@ -214,7 +214,7 @@ open class GraphNode<N : GraphNode<N, G>, G : GraphNodeList<N, G>>(val graphFact
companion object {
private var nextSeen = 0
private val wrapped = Direction.entries.map { DirectionLink(it) }
private val wrapped = Direction.values().map { DirectionLink(it) }
fun link(direction: Direction): Link {
return wrapped[direction.ordinal]

View File

@ -39,6 +39,7 @@ import ru.dbotthepony.mc.otm.capability.moveFluid
import ru.dbotthepony.mc.otm.container.get
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.collect.any
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.ifPresentK
import ru.dbotthepony.mc.otm.core.immutableList
import ru.dbotthepony.mc.otm.core.immutableMap
@ -158,7 +159,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
val drained = cap.drain(toDrain, IFluidHandler.FluidAction.SIMULATE)
if (!drained.isEmpty && drained.amount == 1000) {
player.level.playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS)
player.level.playSound(player, context.blockPos, soundEvent, SoundSource.BLOCKS, 1f, 1f)
val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS
level.setBlock(context.blockPos, newState, Block.UPDATE_ALL)
cap.drain(toDrain, IFluidHandler.FluidAction.EXECUTE)
@ -202,7 +203,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
val fill = cap.fill(toFill, IFluidHandler.FluidAction.SIMULATE)
if (fill != 1000) return InteractionResult.FAIL
player.level.playSound(player, context.blockPos, mapped.second, SoundSource.BLOCKS)
player.level.playSound(player, context.blockPos, mapped.second, SoundSource.BLOCKS, 1f, 1f)
val level = player.level as? ServerLevel ?: return InteractionResult.SUCCESS
level.setBlock(context.blockPos, Blocks.CAULDRON.defaultBlockState(), Block.UPDATE_ALL)
@ -244,7 +245,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_FILL)
if (sound != null) {
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS, 1f, 1f)
}
if (item.count != 1 && !player.level.isClientSide) {
@ -266,7 +267,7 @@ class FluidCapsuleItem(val capacity: IntSupplier) : Item(Properties().stacksTo(6
val sound = moveResult.fluid.fluidType.getSound(moveResult, SoundActions.BUCKET_EMPTY)
if (sound != null) {
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS)
player.level.playSound(player, context.blockPos, sound, SoundSource.BLOCKS, 1f, 1f)
}
if (item.count != 1 && !player.level.isClientSide) {

View File

@ -32,6 +32,7 @@ import ru.dbotthepony.mc.otm.capability.matteryEnergy
import ru.dbotthepony.mc.otm.config.EnergyBalanceValues
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.collect.filter
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.getID
import ru.dbotthepony.mc.otm.core.getValue
import ru.dbotthepony.mc.otm.core.isNotEmpty

View File

@ -13,6 +13,7 @@ import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.config.ItemsConfig
import ru.dbotthepony.mc.otm.container.MatteryContainer
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.math.Decimal
import ru.dbotthepony.mc.otm.matter.IMatterItem
import ru.dbotthepony.mc.otm.core.nbt.set

View File

@ -157,7 +157,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1)
val (ex, ey, ez) = pos
// взрыв в месте удара молотком
val exp = Explosion(attacker.level, attacker, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY_WITH_DECAY else Explosion.BlockInteraction.KEEP)
val exp = Explosion(attacker.level, attacker, ex, ey, ez, 1f, false, if (ToolsConfig.ExplosiveHammer.EXPLOSION_DAMAGE_BLOCKS) Explosion.BlockInteraction.DESTROY else Explosion.BlockInteraction.NONE)
exp.explode()
exp.finalizeExplosion(true)

View File

@ -6,12 +6,12 @@ import com.mojang.datafixers.util.Pair
import com.mojang.serialization.Codec
import com.mojang.serialization.DataResult
import com.mojang.serialization.DynamicOps
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.TagKey
import net.minecraft.world.item.Item
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister
import net.minecraftforge.registries.ForgeRegistries
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.registry.RegistryDelegate
import java.util.*
@ -74,7 +74,7 @@ abstract class AbstractRegistryAction(
}
object TargetCodec : Codec<Either<ResourceLocation, TagKey<Item>>> {
private val tagCodec = TagKey.codec(Registries.ITEM)
private val tagCodec = TagKey.codec(ForgeRegistries.ITEMS.registryKey)
override fun <T : Any> encode(input: Either<ResourceLocation, TagKey<Item>>, ops: DynamicOps<T>, prefix: T): DataResult<T> {
return DataResult.success(input.map(

View File

@ -3,7 +3,6 @@ package ru.dbotthepony.mc.otm.matter
import com.mojang.datafixers.util.Either
import net.minecraft.data.CachedOutput
import net.minecraft.data.DataProvider
import net.minecraft.data.PackOutput
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.TagKey
import net.minecraft.world.item.Item

View File

@ -14,6 +14,7 @@ import net.minecraft.world.item.ItemStack
import net.minecraftforge.network.PacketDistributor
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.addSorted
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.core.map
import ru.dbotthepony.mc.otm.core.readBigInteger

View File

@ -8,6 +8,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler
import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting
import ru.dbotthepony.mc.otm.block.entity.decorative.FluidTankBlockEntity
import ru.dbotthepony.mc.otm.capability.isNotEmpty
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.menu.OutputSlot
import ru.dbotthepony.mc.otm.menu.MatteryMenu
import ru.dbotthepony.mc.otm.menu.MatterySlot

View File

@ -33,7 +33,7 @@ import kotlin.collections.ArrayList
class PainterMenu(
containerId: Int, inventory: Inventory, tile: PainterBlockEntity? = null
) : MatteryMenu(MMenus.PAINTER, containerId, inventory, tile) {
val dyeStored = (DyeColor.entries.toMutableList<DyeColor?>().also { it.add(0, null) }).associateWith { dye ->
val dyeStored = (DyeColor.values().toMutableList<DyeColor?>().also { it.add(0, null) }).associateWith { dye ->
mSynchronizer.ComputedIntField({ tile?.dyeStored(dye) ?: 0 }).also { it.addListener(IntConsumer { rescan() }) }
}

View File

@ -1,14 +1,11 @@
package ru.dbotthepony.mc.otm.recipe
import com.google.gson.JsonObject
import com.mojang.serialization.Codec
import net.minecraft.core.NonNullList
import net.minecraft.core.RegistryAccess
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.CraftingBookCategory
import net.minecraft.world.item.crafting.CraftingRecipe
import net.minecraft.world.item.crafting.Ingredient
import net.minecraft.world.item.crafting.RecipeSerializer
@ -30,10 +27,6 @@ class EnergyContainerRecipe(val parent: ShapedRecipe) : CraftingRecipe, IShapedR
return parent.getResultItem()
}
override fun category(): CraftingBookCategory {
return parent.category()
}
override fun getRemainingItems(p_44004_: CraftingContainer): NonNullList<ItemStack> {
return parent.getRemainingItems(p_44004_)
}

View File

@ -2,17 +2,16 @@ package ru.dbotthepony.mc.otm.recipe
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.NonNullList
import net.minecraft.core.RegistryAccess
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.inventory.CraftingContainer
import net.minecraft.world.item.ItemStack
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
import net.minecraft.world.level.Level
import net.minecraftforge.common.Tags
import ru.dbotthepony.mc.otm.container.util.stream
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.isActuallyEmpty
import ru.dbotthepony.mc.otm.core.isNotEmpty
import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer
@ -61,10 +60,6 @@ class ExplosiveHammerPrimingRecipe(val payload: Ingredient, private val id: Reso
return CODEC
}
override fun category(): CraftingBookCategory {
return CraftingBookCategory.EQUIPMENT
}
override fun getIngredients(): NonNullList<Ingredient> {
return NonNullList.of(Ingredient.of(), Ingredient.of(MItems.EXPLOSIVE_HAMMER), Ingredient.of(Tags.Items.GUNPOWDER), payload)
}

View File

@ -24,6 +24,7 @@ import ru.dbotthepony.mc.otm.core.tagNotNull
import ru.dbotthepony.mc.otm.data.Codec2RecipeSerializer
import ru.dbotthepony.mc.otm.data.DecimalCodec
import ru.dbotthepony.mc.otm.data.IngredientMatrixCodec
import ru.dbotthepony.mc.otm.data.UUIDCodec
import ru.dbotthepony.mc.otm.data.minRange
import ru.dbotthepony.mc.otm.registry.MItems
import ru.dbotthepony.mc.otm.registry.MRecipes
@ -156,7 +157,7 @@ open class MatterEntanglerRecipe(
ItemStack.CODEC.fieldOf("result").forGetter(MatterEntanglerRecipe::result),
Codec.FLOAT.minRange(0f).optionalFieldOf("experience", 0f).forGetter(MatterEntanglerRecipe::experience),
Codec.STRING.optionalFieldOf("uuidKey", "uuid").forGetter(MatterEntanglerRecipe::uuidKey),
UUIDUtil.STRING_CODEC.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid)
UUIDCodec.optionalFieldOf("fixedUuid").forGetter(MatterEntanglerRecipe::fixedUuid)
).apply(it) { a, b, c, d, e, f, g -> MatterEntanglerRecipe(context.id, a, b, c, d, e, f, g) }
}
}

View File

@ -106,7 +106,7 @@ abstract class AbstractPainterRecipe(
wrapperCodec.xmap({ mapOf(it to 1) }, { it.keys.first() }) to Predicate { it.keys.size == 1 && it.values.first() == 1 },
Codec.list(wrapperCodec).xmap({ it.associateWith { 1 } }, { ArrayList(it.keys) }) to Predicate { it.values.all { it == 1 } },
Codec.unboundedMap(wrapperCodec, Codec.INT.minRange(1)) to Predicate { true }
).fieldOf("dyes").xmap({ it.mapKeys { it.key.key } }, { it.mapKeys { k -> DyeColorWrapper.entries.first { k.key == it.key } } })
).fieldOf("dyes").xmap({ it.mapKeys { it.key.key } }, { it.mapKeys { k -> DyeColorWrapper.values().first { k.key == it.key } } })
}
}

View File

@ -4,13 +4,11 @@ import com.google.common.collect.ImmutableList
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.NonNullList
import net.minecraft.core.RegistryAccess
import net.minecraft.nbt.CompoundTag
import net.minecraft.resources.ResourceLocation
import net.minecraft.util.StringRepresentable
import net.minecraft.world.inventory.CraftingContainer
import net.minecraft.world.item.ItemStack
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
@ -74,10 +72,6 @@ class UpgradeRecipe(
return parent.recipe.type
}
override fun category(): CraftingBookCategory {
return parent.recipe.category()
}
enum class OpType : StringRepresentable {
DIRECT {
override val codec: Codec<Direct> = RecordCodecBuilder.create {

View File

@ -78,7 +78,7 @@ object MBlockEntities {
val PAINTER by register(MNames.PAINTER, ::PainterBlockEntity, MBlocks::PAINTER)
val MATTER_ENTANGLER by register(MNames.MATTER_ENTANGLER, ::MatterEntanglerBlockEntity, MBlocks::MATTER_ENTANGLER)
val ENERGY_CABLES: Map<CablesConfig.E, BlockEntityType<*>> = SupplierMap(CablesConfig.E.entries.map { conf ->
val ENERGY_CABLES: Map<CablesConfig.E, BlockEntityType<*>> = SupplierMap(CablesConfig.E.values().map { conf ->
var selfFeed: Supplier<BlockEntityType<*>> = Supplier { TODO() }
selfFeed = register("${conf.name.lowercase()}_energy_cable", { a, b -> SimpleEnergyCableBlockEntity(selfFeed.get(), a, b, conf) }) as Supplier<BlockEntityType<*>>
conf to selfFeed::get

View File

@ -117,7 +117,7 @@ object MBlocks {
val PAINTER: PainterBlock by registry.register(MNames.PAINTER) { PainterBlock() }
val MATTER_ENTANGLER: MatterEntanglerBlock by registry.register(MNames.MATTER_ENTANGLER) { MatterEntanglerBlock() }
val ENERGY_CABLES: Map<CablesConfig.E, EnergyCableBlock> = SupplierMap(CablesConfig.E.entries.map { conf ->
val ENERGY_CABLES: Map<CablesConfig.E, EnergyCableBlock> = SupplierMap(CablesConfig.E.values().map { conf ->
conf to registry.register("${conf.name.lowercase()}_energy_cable") { EnergyCableBlock { a, b -> MBlockEntities.ENERGY_CABLES[conf]!!.create(a, b)!! } }::get
})
@ -226,8 +226,7 @@ object MBlocks {
.explosionResistance(80f)
.noOcclusion()
.destroyTime(3f)
.requiresCorrectToolForDrops(),
SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN
.requiresCorrectToolForDrops()
) {
override fun appendHoverText(
p_49816_: ItemStack,
@ -261,8 +260,7 @@ object MBlocks {
.explosionResistance(80f)
.noOcclusion().destroyTime(3f)
.requiresCorrectToolForDrops()
.isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false },
SoundEvents.IRON_DOOR_CLOSE, SoundEvents.IRON_DOOR_OPEN
.isValidSpawn { _: BlockState, _: BlockGetter, _: BlockPos, _: EntityType<*>? -> false }
) {
override fun appendHoverText(
p_49816_: ItemStack,

View File

@ -1,6 +1,6 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.registries.Registries
import net.minecraft.core.Registry
import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.DeferredRegister
@ -10,7 +10,7 @@ import ru.dbotthepony.mc.otm.item.ProceduralBatteryItem
import ru.dbotthepony.mc.otm.item.exopack.ProceduralExopackSlotUpgradeItem
object MItemFunctionTypes {
private val registry = DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, OverdriveThatMatters.MOD_ID)
private val registry = DeferredRegister.create(Registry.LOOT_FUNCTION_TYPE.key(), OverdriveThatMatters.MOD_ID)
val COPY_TILE_NBT: LootItemFunctionType by registry.register("copy_tile_nbt") { LootItemFunctionType(CopyTileNbtFunction.CODEC) }
val PROCEDURAL_BATTERY: LootItemFunctionType by registry.register(MNames.PROCEDURAL_BATTERY) { LootItemFunctionType(ProceduralBatteryItem.Randomizer.CODEC) }

View File

@ -49,7 +49,7 @@ object MItems {
registry.register(bus)
}
val ENERGY_CABLES: Map<CablesConfig.E, BlockItem> = SupplierMap(CablesConfig.E.entries.map { conf ->
val ENERGY_CABLES: Map<CablesConfig.E, BlockItem> = SupplierMap(CablesConfig.E.values().map { conf ->
conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) }::get
})

View File

@ -1,7 +1,6 @@
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
@ -16,7 +15,7 @@ import ru.dbotthepony.mc.otm.data.condition.KilledByRealPlayerOrIndirectly
import ru.dbotthepony.mc.otm.data.condition.ChanceCondition
object MLootItemConditions {
private val registry = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, OverdriveThatMatters.MOD_ID)
private val registry = DeferredRegister.create(Registry.LOOT_CONDITION_TYPE.key(), OverdriveThatMatters.MOD_ID)
val HAS_EXOPACK: LootItemConditionType by registry.register("has_exopack") { LootItemConditionType(Codec2Serializer(SingletonCodec(HasExoPackCondition))) }
val CHANCE_WITH_PLAYTIME: LootItemConditionType by registry.register("chance_with_playtime") { LootItemConditionType(Codec2Serializer(ChanceWithPlaytimeCondition.CODEC)) }

View File

@ -1,7 +1,6 @@
package ru.dbotthepony.mc.otm.registry
import net.minecraft.client.gui.screens.MenuScreens
import net.minecraft.world.flag.FeatureFlags
import net.minecraft.world.inventory.MenuType
import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent

View File

@ -7,8 +7,8 @@ import net.minecraft.advancements.CriteriaTriggers
import net.minecraft.client.gui.Font
import net.minecraft.client.renderer.item.ItemProperties
import net.minecraft.core.BlockPos
import net.minecraft.core.Registry
import net.minecraft.core.cauldron.CauldronInteraction
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.ai.village.poi.PoiType
@ -236,10 +236,10 @@ object MRegistry {
private fun registerEvent(event: RegisterEvent) {
// mojang moment
if (event.registryKey == Registries.POINT_OF_INTEREST_TYPE) {
if (event.registryKey == Registry.POINT_OF_INTEREST_TYPE_REGISTRY) {
val reg = event.getVanillaRegistry<PoiType>() ?: throw IllegalStateException("POI registry is not a vanilla registry")
event.register(Registries.POINT_OF_INTEREST_TYPE, PoiTypes.BUTCHER.location()) {
event.register(Registry.POINT_OF_INTEREST_TYPE_REGISTRY, PoiTypes.BUTCHER.location()) {
val old = reg[PoiTypes.BUTCHER] ?: throw IllegalStateException("POI with type ${PoiTypes.ARMORER} does not exist")
if (old.`is`(MBlocks.POWERED_SMOKER.defaultBlockState())) {
@ -249,7 +249,7 @@ object MRegistry {
}
}
event.register(Registries.POINT_OF_INTEREST_TYPE, PoiTypes.ARMORER.location()) {
event.register(Registry.POINT_OF_INTEREST_TYPE_REGISTRY, PoiTypes.ARMORER.location()) {
val old = reg[PoiTypes.ARMORER] ?: throw IllegalStateException("POI with type ${PoiTypes.ARMORER} does not exist")
if (old.`is`(MBlocks.POWERED_BLAST_FURNACE.defaultBlockState())) {

View File

@ -14,7 +14,7 @@ object MSoundEvents {
private val registry: DeferredRegister<SoundEvent> = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, OverdriveThatMatters.MOD_ID)
// TODO: 1.19.3
private fun make(name: String) = registry.register(name) { SoundEvent.createVariableRangeEvent(ResourceLocation(OverdriveThatMatters.MOD_ID, name)) }
private fun make(name: String) = registry.register(name) { SoundEvent(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,7 +1,6 @@
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.fml.event.lifecycle.FMLCommonSetupEvent
@ -12,9 +11,9 @@ import ru.dbotthepony.mc.otm.registry.StatNames.POWER_CONSUMED
object MStats {
fun registerVanilla(event: FMLCommonSetupEvent) {
event.enqueueWork {
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)
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)
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

@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.storage
import net.minecraft.network.chat.Component
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.core.copyWithCount
import ru.dbotthepony.mc.otm.core.getValue
import ru.dbotthepony.mc.otm.core.lazy2
import ru.dbotthepony.mc.otm.core.math.toIntSafe