From 3fc94352593172b17aeef30dac9cbd314cee53d8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 1 Jan 2024 23:45:19 +0700 Subject: [PATCH] Some backporting --- .../mc/otm/block/entity/ExperienceStorage.kt | 4 ++-- .../mc/otm/block/entity/MatteryBlockEntity.kt | 2 +- .../otm/block/entity/blackhole/BlackHoleBlockEntity.kt | 3 ++- .../mc/otm/block/entity/blackhole/Explosions.kt | 6 +++--- .../otm/block/entity/decorative/DevChestBlockEntity.kt | 1 + .../block/entity/decorative/FluidTankBlockEntity.kt | 1 + .../otm/block/entity/decorative/PainterBlockEntity.kt | 8 ++++---- .../otm/block/entity/storage/ItemMonitorBlockEntity.kt | 1 + .../block/entity/tech/ChemicalGeneratorBlockEntity.kt | 1 + .../mc/otm/block/entity/tech/PlatePressBlockEntity.kt | 1 + .../otm/block/entity/tech/PoweredFurnaceBlockEntity.kt | 1 + .../mc/otm/client/render/RenderExtensions.kt | 4 ++++ .../otm/client/render/blockentity/HoloSignRenderer.kt | 1 + .../dbotthepony/mc/otm/client/screen/MatteryScreen.kt | 1 + .../mc/otm/client/screen/decorative/PainterScreen.kt | 10 +++++----- .../mc/otm/client/screen/matter/MatterPanelScreen.kt | 2 +- .../mc/otm/client/screen/panels/EditablePanel.kt | 1 + .../mc/otm/client/screen/panels/Panel2Widget.kt | 5 ++--- .../mc/otm/client/screen/panels/button/Buttons.kt | 2 +- .../mc/otm/client/screen/panels/slot/SlotPanel.kt | 2 +- .../mc/otm/client/screen/storage/DriveViewerScreen.kt | 2 +- .../mc/otm/client/screen/storage/ItemMonitorScreen.kt | 8 ++++---- .../mc/otm/client/screen/tech/AndroidStationScreen.kt | 1 + .../mc/otm/client/screen/widget/FluidGaugePanel.kt | 2 +- .../mc/otm/client/screen/widget/MatterGaugePanel.kt | 1 + .../mc/otm/compat/jei/PainterRecipeCategory.kt | 1 + .../mc/otm/compat/vanilla/MatteryChestMenu.kt | 5 ++--- .../dbotthepony/mc/otm/container/ContainerHandler.kt | 1 + .../dbotthepony/mc/otm/container/ContainerHelpers.kt | 1 + .../ru/dbotthepony/mc/otm/container/ShadowContainer.kt | 1 + src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt | 6 ++++++ .../kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt | 6 +++++- .../ru/dbotthepony/mc/otm/core/util/BinaryJson.kt | 2 +- .../ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt | 2 +- .../ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt | 9 +++++---- .../ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt | 1 + .../dbotthepony/mc/otm/item/matter/MatterDustItem.kt | 1 + .../mc/otm/item/tool/ExplosiveHammerItem.kt | 2 +- .../mc/otm/matter/AbstractRegistryAction.kt | 4 ++-- .../ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt | 1 - .../dbotthepony/mc/otm/menu/data/NetworkedItemView.kt | 1 + .../mc/otm/menu/decorative/FluidTankMenu.kt | 1 + .../dbotthepony/mc/otm/menu/decorative/PainterMenu.kt | 2 +- .../dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt | 7 ------- .../mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt | 7 +------ .../dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt | 3 ++- .../ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt | 2 +- .../ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt | 6 ------ .../ru/dbotthepony/mc/otm/registry/MBlockEntities.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt | 8 +++----- .../dbotthepony/mc/otm/registry/MItemFunctionTypes.kt | 4 ++-- .../kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt | 2 +- .../dbotthepony/mc/otm/registry/MLootItemConditions.kt | 3 +-- .../kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt | 1 - .../kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt | 8 ++++---- .../ru/dbotthepony/mc/otm/registry/MSoundEvents.kt | 2 +- .../kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt | 7 +++---- .../ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt | 1 + 59 files changed, 98 insertions(+), 87 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt index 6b4c4db49..105c2386c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/ExperienceStorage.kt @@ -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) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index 06a2416f5..dcf460a57 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -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 } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt index b20cbcc60..5d9e7d54e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/BlackHoleBlockEntity.kt @@ -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 ) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/Explosions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/Explosions.kt index 3f3b8ba2b..9385f3920 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/Explosions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/blackhole/Explosions.kt @@ -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 ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt index 16b68cb47..b9cd7bad3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/DevChestBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt index c3e321746..fe4066eb7 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/FluidTankBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt index 7a65e1450..06e19a6dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/decorative/PainterBlockEntity.kt @@ -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) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt index 062e42e86..cd40b654a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/ItemMonitorBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt index 38597c699..f89c1c39b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/ChemicalGeneratorBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt index 2ba1f2a45..a21cc2d85 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PlatePressBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt index f88b67c25..815036ef9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/PoweredFurnaceBlockEntity.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt index 432d88021..07827dad3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/RenderExtensions.kt @@ -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()) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt index 4e1be4a88..8ab20e1ef 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/render/blockentity/HoloSignRenderer.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 252a9a062..164d72a5c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt index 3f2c4d177..6e9c9b5d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/decorative/PainterScreen.kt @@ -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]) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt index b1d960325..e20b0b524 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/matter/MatterPanelScreen.kt @@ -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) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index 96719477e..98870ac61 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -898,6 +898,7 @@ open class EditablePanel @JvmOverloads constructor( } } + @OptIn(ExperimentalStdlibApi::class) fun tickHover(mouseX: Float, mouseY: Float): Boolean { if (isRemoved) return false diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt index 6cff8a82f..d854fb6b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/Panel2Widget.kt @@ -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>( 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})" } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt index 9d6c1ded8..b0ced26c5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/button/Buttons.kt @@ -440,7 +440,7 @@ class DeviceControls>( 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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt index 5ec271a7d..dd711aa77 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt @@ -100,7 +100,7 @@ open class SlotPanel, 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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt index 95769454c..438e68006 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/DriveViewerScreen.kt @@ -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) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt index 03ea70ec7..7270f291d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/storage/ItemMonitorScreen.kt @@ -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) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt index f4067d725..b9c86e831 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt index 670246d22..dbbb31a42 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/FluidGaugePanel.kt @@ -87,7 +87,7 @@ open class FluidGaugePanel( 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() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt index c31f5db8a..bb80cd200 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/widget/MatterGaugePanel.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt index 440806e40..9b776a7eb 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/jei/PainterRecipeCategory.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt index c726ff6d3..3e32c75cc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt index eefa76b79..556acc488 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHandler.kt @@ -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, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt index c50cd7b5c..8ac0dd6ee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ContainerHelpers.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt index 93c85355e..22a262eea 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/container/ShadowContainer.kt @@ -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(0) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt index 1a3e5ce02..66edfac2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Ext.kt @@ -475,3 +475,9 @@ fun lazy2(a: () -> A, b: A.() -> B): Supplier { } inline val , T : Container> R.value get() = this + +fun ItemStack.copyWithCount(count: Int): ItemStack { + val copy = copy() + copy.count = count + return copy +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt index 69e20e0c1..ea8435620 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt @@ -97,6 +97,10 @@ sealed class Decimal : Number(), Comparable { 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 { } override fun minus(other: BigInteger): Decimal { - return valueOf(-other) + return valueOf(other.negate()) } override fun times(other: BigInteger): Decimal { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt index bd2ae665c..ceabe72df 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/BinaryJson.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt index 38c7b6e0a..30490fd63 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/util/FriendlyStreams.kt @@ -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) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt index e6b2b754e..e4a29b67a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/graph/GraphNode.kt @@ -214,7 +214,7 @@ open class GraphNode, G : GraphNodeList>(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] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt index 1494165ae..3a109b4ec 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/FluidCapsuleItem.kt @@ -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) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt index ab27241bd..f12f06602 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/QuantumBatteryItem.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt index 5f02f26c9..ce4e68652 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/matter/MatterDustItem.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt index da381bb92..ad892eec5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt @@ -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) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt index d03613743..2f4e20793 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/AbstractRegistryAction.kt @@ -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>> { - private val tagCodec = TagKey.codec(Registries.ITEM) + private val tagCodec = TagKey.codec(ForgeRegistries.ITEMS.registryKey) override fun encode(input: Either>, ops: DynamicOps, prefix: T): DataResult { return DataResult.success(input.map( diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt index 6f45e0283..a49348573 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/matter/MatterDataProvider.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt index 8ded60070..3bf3e8b60 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt index 401057a94..2d0e1d3da 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/FluidTankMenu.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt index d61b81d0b..c96dacfcd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/decorative/PainterMenu.kt @@ -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().also { it.add(0, null) }).associateWith { dye -> + val dyeStored = (DyeColor.values().toMutableList().also { it.add(0, null) }).associateWith { dye -> mSynchronizer.ComputedIntField({ tile?.dyeStored(dye) ?: 0 }).also { it.addListener(IntConsumer { rescan() }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt index 8990a7ca2..1074f4c29 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/EnergyContainerRecipe.kt @@ -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 { return parent.getRemainingItems(p_44004_) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt index dbd47c23e..8d1b02c7e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/ExplosiveHammerPrimingRecipe.kt @@ -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 { return NonNullList.of(Ingredient.of(), Ingredient.of(MItems.EXPLOSIVE_HAMMER), Ingredient.of(Tags.Items.GUNPOWDER), payload) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt index 1bd928749..f3a90951e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/MatterEntanglerRecipe.kt @@ -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) } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt index b726497b5..a70c84369 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/PainterRecipe.kt @@ -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 } } }) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt index 01eb1200a..7f8d516cd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/recipe/UpgradeRecipe.kt @@ -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 = RecordCodecBuilder.create { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt index 9036fc742..7db71635a 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlockEntities.kt @@ -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> = SupplierMap(CablesConfig.E.entries.map { conf -> + val ENERGY_CABLES: Map> = SupplierMap(CablesConfig.E.values().map { conf -> var selfFeed: Supplier> = Supplier { TODO() } selfFeed = register("${conf.name.lowercase()}_energy_cable", { a, b -> SimpleEnergyCableBlockEntity(selfFeed.get(), a, b, conf) }) as Supplier> conf to selfFeed::get diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt index ef5561e86..c8243eb24 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MBlocks.kt @@ -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 = SupplierMap(CablesConfig.E.entries.map { conf -> + val ENERGY_CABLES: Map = 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, diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt index 16a3b4d89..c17228d89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -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) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt index bc94ff668..6aa15db64 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItems.kt @@ -49,7 +49,7 @@ object MItems { registry.register(bus) } - val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.entries.map { conf -> + val ENERGY_CABLES: Map = SupplierMap(CablesConfig.E.values().map { conf -> conf to registry.register("${conf.name.lowercase()}_energy_cable") { BlockItem(MBlocks.ENERGY_CABLES[conf]!!, DEFAULT_PROPERTIES) }::get }) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt index ad46b96a6..3c93285aa 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MLootItemConditions.kt @@ -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)) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt index e308ef926..4be7d38f3 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MMenus.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index 211e305d3..0a15d6bd5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -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() ?: 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())) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt index d1c3d73b7..bacaa9fee 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MSoundEvents.kt @@ -14,7 +14,7 @@ object MSoundEvents { private val registry: DeferredRegister = 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") diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt index efc37a888..d362c8624 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MStats.kt @@ -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] diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt index 260ca07bc..367c5d1ff 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/storage/ItemStorageStack.kt @@ -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